body, html {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    height: 100%; /* Ensure html and body take full height */
    overflow: hidden; /* Prevent body scroll */
}

.hidden {
    display: none !important;
}

.container {
    display: flex;
    height: 100%; /* Ensure container takes full height */
}

/* 사이드바 */
.sidebar {
    width: 250px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid #34495e;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 16px; /* Make title smaller to fit two lines */
    line-height: 1.25;
}

.sidebar-header h2 .brand-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
}

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

.menu ul li a {
    display: block;
    padding: 15px 20px;
    color: white;
    text-decoration: none;
    transition: background-color 0.3s;
}

.menu ul li a:hover, .menu ul li a.active {
    background-color: #34495e;
}

/* Language toggle buttons in sidebar */
.menu ul li.lang-toggle {
    display: flex;
    gap: 10px;
    padding: 12px 20px;
}
.menu ul li.lang-toggle .lang-btn {
    flex: 1 1 0;
    text-align: center;
    padding: 8px 0;
    border: 1px solid #4b5d6e;
    background: #2c3e50;
    color: #ecf0f1;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.menu ul li.lang-toggle .lang-btn:hover {
    background: #34495e;
}
.menu ul li.lang-toggle .lang-btn.active {
    background: #16a085;
    border-color: #16a085;
    color: #ffffff;
}

/* Sidebar contact footer */
.sidebar-contact {
    margin-top: auto; /* push near bottom */
    margin-bottom: 24px; /* lift slightly from absolute bottom */
    padding: 12px 20px 18px 20px;
    border-top: 1px solid #34495e;
    color: #ecf0f1;
}
.sidebar-contact .title { margin: 0 0 6px 0; font-weight: 800; font-size: 1.15rem; color: #ffffff; }
.sidebar-contact .subtitle { margin: 0 0 8px 0; font-size: 0.9rem; color: #bdc3c7; }
.sidebar-contact .line { margin: 2px 0; font-size: 0.95rem; color: #ecf0f1; }

/* 메인 콘텐츠 */
.main-content {
    flex-grow: 1;
    position: relative; /* Crucial for absolute positioning of panel */
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.view-container {
    padding: 30px;
    flex-grow: 1;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#view-monitoring {
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.main-header {
    border-bottom: 1px solid #ddd;
    padding: 30px 30px 15px 30px;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.main-header h1 {
    margin: 0;
}

/* 대시보드 뷰 */
.chart-container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 60px;
    height: 350px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-container h3 {
    margin-top: 0;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.card {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 5px solid #ccc;
    position: relative; /* For popup positioning */
}

.card.status-normal { border-left-color: #2ecc71; }
.card.status-warning { border-left-color: #f1c40f; }
.card.status-critical { border-left-color: #e74c3c; }
/* New statuses matching updated legend */
.card.status-observe { border-left-color: #ff6b6b; }
.card.status-severe { border-left-color: #c40000; }

/* Small popup on card */
.card-popup {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    border-radius: 6px;
    padding: 10px 12px;
    z-index: 5;
}
.card-popup .view-detail-btn {
    padding: 6px 10px;
    background-color: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}
.card-popup .view-detail-btn:hover {
    background-color: #34495e;
}

.card h3 { margin-top: 0; font-size: 1.2rem; color: #333; }
.card .info { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 15px; font-size: 0.88rem; }
.card .info .info-item { min-width: 0; }
.card .info .label { display: block; color: #666; font-size: 0.8rem; white-space: normal; line-height: 1.1; }
.card .info .value { display: block; font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; }
.card .health-index { margin-top: 15px; font-size: 1.1rem; font-weight: bold; }
.health-index-normal { color: #2ecc71; }
.health-index-warning { color: #f1c40f; }
/* Updated: split critical into observe and severe */
.health-index-observe { color: #ff6b6b; }
.health-index-severe { color: #c40000; }
.card .event-tracker { margin-top: 15px; font-size: 0.85rem; color: #555; }
.event-tracker .count-warning { font-weight: bold; color: #f1c40f; }
.event-tracker .count-critical { font-weight: bold; color: #e74c3c; }

/* 실시간 모니터링 뷰 */
.monitoring-container {
    display: flex;
    flex-grow: 1;
    gap: 20px;
    padding: 0 30px 30px 30px;
    min-height: 800px; /* Further increased height for charts */
}

.monitoring-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
    min-height: 0;
}

.chart-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chart-card.large {
    flex: 1; /* Take 1 part of available space */
}

.sub-charts {
    flex: 2; /* Take 2 parts of available space */
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 20px;
    min-height: 0;
}

.chart-card.small {
    min-height: 0;
}

.chart-card h3, .chart-card h4 {
    margin-top: 0;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.chart-wrapper {
    position: relative;
    flex-grow: 1;
    min-height: 0;
}

.motor-list-panel {
    position: absolute; /* Overlay the charts */
    top: 80px; /* Adjusted to start below header and toggle button */
    right: 0; /* Start at right edge */
    width: 280px; /* Increased width for better readability */
    height: calc(100% - 80px); /* Adjusted height */
    background: #fff;
    border-radius: 8px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    transition: transform 0.4s ease; /* Smooth slide animation */
    transform: translateX(100%); /* Initially hidden off-screen */
    display: flex;
    flex-direction: column;
    z-index: 50; /* Ensure it's above charts */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.motor-list-panel.open {
    transform: translateX(0); /* Slide in */
}

.motor-list-panel h3 { margin: 20px 20px 0; }
.sort-options {
    margin: 15px 20px;
    display: flex;
    gap: 5px;
}

.sort-options button {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: #f7f7f7;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sort-options button:hover {
    background: #eee;
}

.sort-options button .arrow {
    font-size: 0.8em;
    line-height: 1;
}

#motor-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    overflow-x: hidden; /* Prevent horizontal scroll */
    flex-grow: 1;
}

#motor-list li {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-width: 0; /* Allow children to shrink and ellipsis */
}

#motor-list li:hover {
    background-color: #f0f2f5;
}

#motor-list li.active {
    background-color: #e0e7ff;
    font-weight: bold;
}

/* Truncate long motor names with ellipsis */
#motor-list li span:first-child {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}

/* Keep HI value compact */
#motor-list li span:last-child {
    flex: 0 0 auto;
}

.panel-toggle-wrapper {
    position: absolute; /* positioned relative to .main-content */
    top: 80px; /* align with panel top below header line */
    right: 30px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-toggle-label {
    font-size: 0.9rem;
    color: #555;
    font-weight: bold;
}

.panel-toggle-btn {
    width: 40px;
    height: 40px;
    background: #2c3e50;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
    flex-shrink: 0;
}

.panel-toggle-btn span {
    width: 20px;
    height: 2px;
    background: white;
    display: block;
    transition: transform 0.3s ease;
}

.panel-toggle-btn.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.panel-toggle-btn.open span:nth-child(2) { opacity: 0; }
.panel-toggle-btn.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Settings Page Specific Styles */
.settings-section {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 30px;
}

.settings-section h2 {
    margin-top: 0;
    color: #333;
    margin-bottom: 20px;
}

.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.toggle-label {
    font-size: 1.1rem;
    font-weight: bold;
    color: #555;
}

/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:focus + .slider {
    box-shadow: 0 0 1px #2196F3;
}

input:checked + .slider:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

/* Diagnose Page Specific Styles */
.diagnose-section {
    background-color: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin: 0 30px 30px;
}

/* Limit parent white box width on diagnose page only */
#view-diagnose .diagnose-section {
    max-width: 1100px !important; /* cap parent width for diagnose only */
    width: 100%;
    margin-left: 0; /* keep left-aligned */
    margin-right: 0;
}

/* Dashboard max width */
#view-dashboard .chart-container,
#view-dashboard .dashboard {
    max-width: 1300px;
    width: 100%;
    margin-left: 0; /* left-aligned (no centering) */
    margin-right: 0;
    box-sizing: border-box;
}

/* Monitoring max width */
#view-monitoring .monitoring-container {
    max-width: 1300px;
    margin-left: 0;
    margin-right: 0;
}

.diagnose-section h2 {
    margin-top: 0;
    color: #333;
    margin-bottom: 20px;
}

.file-input-info {
    font-size: 0.85rem;
    color: #666;
    margin-left: 10px;
    white-space: nowrap; /* Prevent text from wrapping */
}

#upload-form { display: block; }

#upload-form input[type="file"] {
    display: none;
}

.custom-file-upload {
    display: block;
    width: 100%; /* fixed width within column */
    max-width: 100%;
    min-height: 24px; /* much smaller vertical size */
    border: 1px solid #ddd;
    padding: 4px 8px; /* tighter padding */
    border-radius: 4px;
    cursor: pointer;
    background-color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.custom-file-upload:hover {
    background-color: #f7f7f7;
}

.custom-file-upload.drag-over {
    border-color: #2196F3; /* Blue border */
    background-color: #e3f2fd; /* Light blue background */
}

#file-name-display {
    color: #555;
    display: inline-block;
    max-width: 92%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-hint { font-size: 0.85em; color: #666; }
.upload-subhint { margin-top: 4px; font-size: 0.9rem; color: #666; }
.file-list { margin-top: 6px; font-size: 0.9rem; color: #333; max-height: 140px; overflow-y: auto; }
.file-list .file-item { display: flex; align-items: center; gap: 8px; padding: 2px 0; width: 100%; box-sizing: border-box; }
.file-list .file-name { flex: 0 1 75%; max-width: 75%; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: inline-block; }
.file-list .file-remove { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 50%; border: 1px solid #c9c9c9; background: #f5f5f5; color: #666; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; line-height: 1; cursor: pointer; }
.file-list .file-remove:hover { background: #eaeaea; color: #333; }

/* Locator box for diagnose page */
.locator-box {
    margin-top: 16px;
    padding: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
}
.locator-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.locator-box h3 { margin: 0; }
.locator-header-inner {
    display: grid;
    grid-template-columns: 240px 240px; /* match locator-grid columns */
    gap: 12px 28px;                     /* increase horizontal gap to shift right */
    align-items: center;
    width: max-content;                 /* shrink to content width */
}
.locator-header-inner .auto-btn-wrap { justify-self: end; }
@media (max-width: 900px) {
  .locator-header-inner { grid-template-columns: 1fr; width: 100%; }
  .locator-header-inner .auto-btn-wrap { justify-self: end; }
}
.autodetect-btn { padding: 4px 10px; font-size: 0.85rem; line-height: 1.1; }
.auto-btn-wrap { position: relative; display: inline-block; }
.tooltip { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); background: #333; color: #fff; padding: 6px 8px; border-radius: 4px; font-size: 12px; white-space: nowrap; margin-top: 6px; z-index: 10; }
.tooltip.hidden { display: none; }

/* Info icon and popup for meta/data locator */
.locator-title-wrap { display: flex; align-items: center; gap: 8px; }
.info-icon-btn { width: 18px; height: 18px; border-radius: 50%; background: #2c3e50; color: #fff; font-weight: 800; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; display: inline-block; }
.info-icon-btn:hover { background: #34495e; }
.locator-title-wrap { position: relative; }
.info-popup { position: absolute; top: 28px; left: 4px; background: #ffffff; border: 1px solid #e0e0e0; box-shadow: 0 4px 12px rgba(0,0,0,0.12); border-radius: 6px; padding: 10px 12px; font-size: 0.9rem; color: #333; z-index: 1000; width: 504px; max-width: calc(100vw - 48px); display: none; }
.info-toggle { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }
.info-toggle:checked ~ .info-popup { display: block !important; }
.hl-red-bold { color: #c40000; font-weight: 800; }
.info-popup ul { margin: 0; padding-left: 16px; }
.info-popup.hidden { display: none; }
.locator-grid {
    display: grid;
    grid-template-columns: 240px 240px; /* more compact columns */
    gap: 12px 28px;        /* increase horizontal gap to shift right col */
    align-items: start;
    width: max-content;    /* shrink-wrap to content */
    margin: 0;             /* left-align inside locator box */
}
.locator-col { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 900px) {
  .locator-grid { grid-template-columns: 1fr; width: 100%; }
}
.locator-field-group { display: flex; flex-direction: column; gap: 12px; }
.locator-grid .row {
    display: flex;
    gap: 8px;
}
.locator-grid input[type="number"], .locator-grid input[type="text"] {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 50%; /* reduce horizontal width to about half */
    box-sizing: border-box;
}
.locator-grid .row.current-rows { display: flex; flex-direction: column; gap: 6px; }
.locator-grid .row.current-rows .phase-row { display: flex; align-items: center; gap: 8px; }
.locator-grid .row.current-rows .phase-label { width: 14px; display: inline-block; text-align: right; color: #333; }
.locator-grid .row.current-rows .phase-controls { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px dashed transparent; border-radius: 6px; cursor: move; flex: 1; }
.locator-grid .row.current-rows .phase-controls.drag-over { border-color: #8aa8f8; background: #f5f8ff; }
.locator-grid .row.current-rows .phase-controls.dragging { opacity: 0.6; }
.locator-grid .row.current-rows .drag-handle { width: 10px; height: 22px; margin-left: 4px; background: repeating-linear-gradient( to bottom, #999, #999 2px, transparent 2px, transparent 4px ); border-radius: 2px; cursor: grab; flex: 0 0 auto; }
/* Shrink specific meta inputs to ~6 digits visual width */
.locator-grid .row input[name$="_row"],
.locator-grid .row input[name$="_col"] {
    width: 9ch; /* compact for indices */
}
.locator-grid .row input[name$="_value"] {
    width: 12ch; /* moderate width for value fields */
}
/* Slightly wider sheet name box */
.locator-grid .row input[name="sheet_name"] {
    width: 64%;
}

.locator-box .hint {
    margin-top: 8px;
    color: #666;
    font-size: 0.9rem;
}

.locator-box label .detected {
    color: #2c3e50;
    margin-left: 6px;
    font-weight: normal;
    font-size: 0.85em;
}

.locator-field.missing {
    border: 1px dashed #e74c3c;
    padding: 8px;
    border-radius: 4px;
    /* Slightly extend horizontal length (half of previous) */
    width: calc(100% + 4px);
    margin-left: -2px;
    margin-right: -2px;
}

#upload-form button {
    padding: 10px 20px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#upload-form button:hover {
    background-color: #34495e;
}

/* Disabled button appearance */
#upload-form button:disabled,
.autodetect-btn:disabled,
.analyze-btn:disabled {
    background-color: #bdbdbd;
    color: #f2f2f2;
    cursor: not-allowed;
}

.result-container h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #333;
}

/* Layout: left meta, right upload+history */
.root-vars { /* no-op selector to group vars for readability */ }
:root {
    --rhs-box-width: 440px; /* ~20% wider than previous 364px */
    --grid-gap: 40px;
    --grid-max: 1100px; /* requested parent max width */
    --left-col-max: calc(var(--grid-max) - (var(--rhs-box-width) + var(--grid-gap)));
}
.diagnose-grid {
    display: grid;
    grid-template-columns: fit-content(var(--left-col-max)) var(--rhs-box-width);
    gap: var(--grid-gap);
    align-items: start;
    width: max-content;   /* shrink-wrap to content, avoid stretching */
    max-width: 100%;      /* but never exceed viewport width */
}
.left-col { min-width: 0; }
.right-col { min-width: 0; width: var(--rhs-box-width); display: flex; flex-direction: column; gap: 16px; }
.upload-panel { display: flex; flex-direction: column; align-items: flex-start; }
.upload-panel .custom-file-upload { width: 95%; max-width: 100%; }
/* Upload wrapper box styled like meta box */
.upload-box { padding: 16px; border: 1px solid #e0e0e0; border-radius: 6px; background: #fafafa; width: 100%; box-sizing: border-box; }
.upload-box-title { margin: 0 0 8px 0; color: #333; }
.sample-download-ui { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; }
.sample-select { padding: 6px 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 0.9rem; width: auto; max-width: 65%; }
.download-btn { padding: 6px 10px; border: 1px solid #2c3e50; background: #2c3e50; color: #fff; border-radius: 4px; cursor: pointer; }
.download-btn:disabled { opacity: 0.5; cursor: not-allowed; }
/* Compact bar above upload box */
.sample-download-bar { margin-bottom: 10px; padding: 6px 8px; border: 1px solid #e0e0e0; border-radius: 6px; background: #fafafa; display: flex; align-items: center; justify-content: flex-end; }
.sample-download-bar .sample-select { padding: 4px 6px; font-size: 0.85rem; width: auto; max-width: 60%; }
.sample-download-bar .download-btn { padding: 4px 8px; }
.locator-actions { text-align: center; margin-top: 12px; }
.diagnose-history {
    width: 100%; /* match upload box (fills parent) */
    min-height: 50vh; /* much longer blank area */
    height: auto;
    overflow: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    background: #fff;
    box-sizing: border-box;
}
.diagnose-history .history-header { font-weight: bold; margin-bottom: 8px; }
.diagnose-history .history-note { font-size: 0.85rem; color: #666; margin-bottom: 10px; }
/* History clear button */
.diagnose-history .history-header { display: flex; justify-content: flex-start; align-items: center; }
.history-clear-btn { font-size: 0.8rem; padding: 4px 8px; border: 1px solid #ddd; background: #f7f7f7; border-radius: 4px; cursor: pointer; }
.history-clear-btn { margin-left: auto; }
.history-clear-btn:hover { background: #eee; }
/* Card style for history items */
.diagnose-history #history-list > div {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
}

/* Removed analysis-feed placeholder */

.progress-bar-container {
    position: relative;
    background-color: #eee;
    height: 30px;
    border-radius: 15px;
    margin-bottom: 15px;
}

.progress-bar {
    height: 100%;
    background-color: #2ecc71; /* Green for normal */
    border-radius: 15px;
    transition: width 0.5s ease-in-out;
}

.progress-marker {
    position: absolute;
    left: 50%;
    top: -5px;
    bottom: -5px;
    width: 4px;
    background-color: red;
    border-radius: 2px;
}

.progress-labels {
    display: flex;
    justify-content: space-between;
    padding: 0 10px;
    margin-top: 5px;
    font-size: 0.9rem;
    color: #555;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.result-container > h3 + .progress-bar-container {
    margin-bottom: 95px;
}

.detail-item h4 {
    margin-top: 0;
    margin-bottom: 10px;
}


/* Styles for progress bar value */
.progress-value {
    position: absolute;
    left: 52%; /* Position it slightly to the right of the 50% marker */
    top: 50%;
    transform: translateY(-50%);
    color: #333;
    font-weight: bold;
    font-size: 0.9rem;
    background-color: rgba(255, 255, 255, 0.7);
    padding: 2px 5px;
    border-radius: 3px;
}

/* Styles for Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent; /* Removed the white overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-box {
    background-color: rgba(44, 62, 80, 0.9); /* Dark, semi-transparent background */
    padding: 40px 50px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.spinner {
    border: 8px solid rgba(243, 243, 243, 0.3); /* Lighter grey for dark background */
    border-top: 8px solid #ffffff; /* White */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: 25px;
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffffff; /* White text */
}

.noise-warning-text {
    color: red;
    font-size: 0.75em; /* Half the size of a typical h2 */
    font-weight: normal; /* To make it less prominent than the main heading */
    margin-left: 10px; /* Some spacing from the main heading */
}

/* Contact section (business footer) */
.contact-section { margin: 30px 0 40px; }
.contact-grid {
    display: grid;
    grid-template-columns: 15% 70% 15%;
    width: 100%;
    box-sizing: border-box;
}
.contact-inner {
    grid-column: 2 / 3;
    text-align: left;
    /* subtle card look to match UI */
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    padding: 16px 20px;
}
.contact-title { margin: 0 0 6px 0; font-weight: 700; font-size: 1rem; color: #2c3e50; }
.contact-subtitle { margin: 0 0 10px 0; font-size: 0.92rem; color: #555; }
.contact-line { margin: 2px 0; font-size: 0.95rem; color: #333; }

@media (max-width: 900px) {
  .contact-grid { grid-template-columns: 5% 90% 5%; }
}

/* Settings page additions */
.intro-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    padding: 48px 24px; /* taller intro */
    margin: 0 30px 24px 30px; /* align with page padding */
    text-align: center;
}
.intro-inner { max-width: 900px; margin: 0 auto; }
.intro-title { margin: 0 0 12px 0; color: #2c3e50; }
.intro-line { margin: 6px 0; color: #444; font-size: 1rem; line-height: 1.5; }
.intro-contact { margin-top: 12px; color: #333; font-weight: 600; line-height: 1.5; }

.settings-card {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
    padding: 16px 24px;
    margin: 0 30px 24px 30px;
}

/* Quick link small cards on settings intro */
/* Inline links inside intro text */
.inline-link {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    font-size: 0.9em; /* slightly smaller */
    color: #2c3e50;
    text-decoration: none;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
.inline-link:hover {
    background: #f2f6ff;
    border-color: #c7d2fe;
    color: #1f2d3d;
}
