body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: #f0f2f5; color: #333; margin: 0; padding: 20px; transition: background-color 0.3s, color 0.3s; }
.container { display: grid; grid-template-columns: repeat(12, 1fr); gap: 20px; max-width: 1800px; margin: auto; }
.card { position: relative; background: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); padding: 20px; display: flex; flex-direction: column; transition: background-color 0.3s, grid-column 0.3s ease, grid-row 0.3s ease; }
.header-card { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; padding: 10px 20px; margin-bottom: 0; flex-wrap: wrap; gap: 20px; }
h1 { margin: 0; font-size: 1.8em; color: #1c1e21; }

.header-controls { display: flex; align-items: center; gap: 20px; }
#node-selector { font-size: 1em; padding: 8px; border-radius: 6px; }
#node-selector .node-link { margin: 2px 4px; padding: 4px 8px; border-radius: 4px; border: 1px solid transparent; display: inline-block; text-decoration: none; color: #007bff; cursor: pointer; }
#node-selector .node-link:hover { background-color: rgba(0,0,0,0.05); border-color: #ddd; }
#node-selector .node-link.active { font-weight: bold; background-color: #007bff; color: white; border-color: #007bff; }

@media (prefers-color-scheme: dark) {
    #node-selector .node-link:hover { background-color: rgba(255,255,255,0.1); border-color: #444; }
    #node-selector .node-link.active { background-color: #4dabf7; color: #121212; border-color: #4dabf7; }
}

h3 { border-bottom: 1px solid #ddd; padding-bottom: 8px; margin-bottom: 15px; }
h5 { margin-top: 0; margin-bottom: 10px; font-size: 1em; }
.card-title { margin-top: 0; }
.card-content { flex-grow: 1; }
.table-container { overflow-x: auto; }

/* Note: grid-column and grid-row for cards are now set dynamically by JavaScript */
#map { height: 620px; border-radius: 8px; background-color: #aad3df; }

.stat { text-align: center; }
.stat-value { font-size: 2em; font-weight: bold; }
.stat-label { font-size: 0.9em; color: #606770; }
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 25px; }

.info-table { width: 100%; border-collapse: collapse; font-size: 0.9em; }
.info-table th, .info-table td { text-align: left; padding: 8px; border-bottom: 1px solid #eee; vertical-align: top; }
.info-table th { color: #606770; font-weight: 600; }
.info-table th.numeric, .info-table td.numeric { text-align: right; white-space: nowrap; }
.piece-id { font-family: monospace; font-size: 0.9em; white-space: nowrap; }

/* Styles for sortable table headers */
.info-table th[data-column] { cursor: pointer; position: relative; padding-right: 20px; }
.info-table th[data-column]::after { content: ''; position: absolute; right: 5px; top: 50%; transform: translateY(-50%); border: 4px solid transparent; opacity: 0.3; }
.info-table th[data-column].sort-asc::after { border-bottom-color: #333; }
.info-table th[data-column].sort-desc::after { border-top-color: #333; }
.info-table th[data-column]:hover::after { opacity: 0.7; }
.info-table th[data-column].sort-asc::after, .info-table th[data-column].sort-desc::after { opacity: 1; }

.chart-header { display: flex; justify-content: space-between; align-items: center; }
.chart-header h3 { border-bottom: none; margin-bottom: 15px; }
.toggle-link { font-size: 0.8em; cursor: pointer; text-decoration: none; color: #007bff; margin: 0 4px; }
.toggle-link.active { font-weight: bold; text-decoration: underline; }
.toggle-link.disabled { color: #888; cursor: not-allowed; text-decoration: none; }
#aggregation-toggles { text-align: right; margin-top: 4px; font-size: 0.9em; }

#analysis-card .stats-grid {
    grid-template-columns: 2.5fr 2fr 1.5fr 1.5fr;
    gap: 30px;
}
#analysis-card .reason-cell {
    white-space: normal;
    word-break: break-word;
}
#performance-card .card-content,
#satellite-card .card-content {
    position: relative;
    height: 350px;
}
#size-charts-card .card-content {
    position: relative;
    height: 600px;
}


.rate-good { color: #22c55e; }
.rate-ok { color: #f59e0b; }
.rate-bad { color: #ef4444; }

.card-header-flex { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #ddd; padding-bottom: 8px; margin-bottom: 15px; }
.card-header-flex .card-title { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
/* Ensure no duplicate short underline inside card headers */
.card-header-flex h3 { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
#toggle-map-size-btn { background: none; border: 1px solid transparent; border-radius: 4px; cursor: pointer; font-size: 1.5em; padding: 0; line-height: 1; color: #606770; transition: background-color 0.2s; }
#toggle-map-size-btn:hover { background-color: rgba(0,0,0,0.05); border-color: #ddd; }

body.map-maximized { overflow: hidden; }

#map-card.maximized { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; margin: 0; border-radius: 0; padding: 15px; box-sizing: border-box; }
#map-card.maximized .card-header-flex { margin-bottom: 10px; }
#map-card.maximized #map { height: calc(100% - 50px); }

.card.is-hidden { display: none; }

/* --- New Display Menu Styles --- */
#display-menu-container { position: relative; }
#display-menu-btn {
    font-size: 0.9em;
    padding: 8px 12px;
    border-radius: 6px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: background-color 0.2s;
}
#display-menu-btn:hover { background-color: #e9ecef; }
#display-menu-dropdown {
    position: absolute;
    top: calc(100% + 5px);
    right: 0;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 15px;
    z-index: 1001;
    min-width: 280px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}
#display-menu-dropdown.visible { display: block; }
#display-menu-dropdown h5 { margin-top: 0; margin-bottom: 10px; font-size: 1em; color: #333; padding-bottom: 5px; border-bottom: 1px solid #eee; }
#display-menu-dropdown label { display: flex; align-items: center; padding: 6px 0; cursor: pointer; user-select: none; font-size: 0.95em; }
#display-menu-dropdown label input { margin-right: 10px; transform: scale(1.1); }

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
    body { background-color: #121212; color: #e0e0e0; }
    .card { background-color: #1e1e1e; box-shadow: none; border: 1px solid #333; }
    h1, h3, h5 { color: #ffffff; }
    h3, .card-header-flex { border-bottom-color: #444; }
    .stat-label { color: #888; }
    .info-table th, .info-table td { border-bottom-color: #333; }
    .info-table th { color: #aaa; }
    .info-table th[data-column].sort-asc::after { border-bottom-color: #aaa; }
    .info-table th[data-column].sort-desc::after { border-top-color: #aaa; }
    .toggle-link, #node-selector .node-link { color: #4dabf7; }
    .toggle-link.disabled { color: #555; }
    #map { background-color: #333; }
    .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(95%) contrast(90%); }
    #toggle-map-size-btn { color: #aaa; }
    #toggle-map-size-btn:hover { background-color: rgba(255,255,255,0.1); border-color: #444; }

    /* Dark mode for display menu */
    #display-menu-btn { background: #343a40; border-color: #495057; color: #e0e0e0; }
    #display-menu-btn:hover { background: #495057; }
    #display-menu-dropdown { background: #2a2a2a; border-color: #555; }
    #display-menu-dropdown h5 { color: #fff; border-bottom-color: #444; }
}

/* --- Phase 3: Enhanced Monitoring Styles --- */

/* Reputation Card */
#reputation-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.reputation-satellite {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f8f9fa;
}

.reputation-satellite-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.reputation-satellite-name {
    font-weight: 600;
    font-size: 1.1em;
}

.reputation-scores {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.reputation-score-item {
    text-align: center;
}

.reputation-score-value {
    font-size: 1.5em;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.reputation-score-label {
    font-size: 0.85em;
    color: #606770;
    margin-top: 4px;
}

.trend-arrow {
    font-size: 0.8em;
    margin-left: 4px;
}

.trend-up { color: #22c55e; }
.trend-down { color: #ef4444; }
.trend-stable { color: #888; }

/* Storage Health Card */
.storage-capacity-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    margin: 15px 0;
}

.storage-segment {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    color: white;
    font-weight: 600;
}

.storage-used { background: #0ea5e9; }
.storage-trash { background: #f59e0b; }
.storage-free { background: #22c55e; }

/* Latency Card */
#latency-stats .stat-value.latency-good { color: #22c55e; }
#latency-stats .stat-value.latency-ok { color: #f59e0b; }
#latency-stats .stat-value.latency-bad { color: #ef4444; }

/* Alerts Panel */
.alerts-badge {
    background: #ef4444;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: bold;
    min-width: 24px;
    text-align: center;
}

.alerts-badge.no-alerts {
    background: #22c55e;
}

.alert-item {
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.alert-item.critical {
    background: #fee;
    border-color: #ef4444;
}

.alert-item.warning {
    background: #fffbeb;
    border-color: #f59e0b;
}

.alert-item.info {
    background: #eff6ff;
    border-color: #3b82f6;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert-message {
    font-size: 0.9em;
    color: #606770;
}

.alert-time {
    font-size: 0.8em;
    color: #888;
    margin-top: 4px;
}

.alert-dismiss {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0 4px;
    line-height: 1;
}

.alert-dismiss:hover {
    color: #333;
}

.no-alerts-message, .loading-message {
    text-align: center;
    color: #888;
    padding: 20px;
}

/* Dark mode for Phase 3 components */
@media (prefers-color-scheme: dark) {
    .reputation-satellite {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .reputation-score-label {
        color: #aaa;
    }
    
    .storage-capacity-bar {
        background: #333;
    }
    
    .alert-item.critical {
        background: #3d1a1a;
        border-color: #ef4444;
    }
    
    .alert-item.warning {
        background: #3d2e1a;
        border-color: #f59e0b;
    }
    
    .alert-item.info {
        background: #1a2a3d;
        border-color: #3b82f6;
    }
    
    .alert-message, .alert-time {
        color: #aaa;
    }
    
    .alert-dismiss:hover {
        color: #fff;
    }
    
    .no-alerts-message, .loading-message {
        color: #666;
    }
}

/* Phase 4: Alerts Panel Styles */

.alert-badge {
    position: relative;
    display: inline-block;
}

.alert-badge .btn-icon {
    position: relative;
    padding: 8px 12px;
    font-size: 16px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.alert-badge .btn-icon:hover {
    background: #e9ecef;
}

.alert-badge .badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

.alert-badge .badge.hidden {
    display: none;
}

.alert-badge .badge.has-critical {
    background: #e74c3c;
    animation: pulse 2s infinite;
}

.alert-badge .badge.has-warning {
    background: #f39c12;
}

.alert-badge.flash {
    animation: flash 0.5s 4;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.alerts-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 450px;
    max-height: 80vh;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s, border-color 0.3s;
}

.alerts-panel.hidden {
    display: none;
}

.alerts-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #34495e;
    color: white;
    border-bottom: 1px solid #2c3e50;
}

.alerts-panel-header h3 {
    margin: 0;
    font-size: 18px;
    border-bottom: none;
}

.alerts-panel-header .btn-icon {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    line-height: 1;
    transition: opacity 0.2s;
}

.alerts-panel-header .btn-icon:hover {
    opacity: 0.8;
}

.alerts-panel-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    background: #f8f9fa;
}

.alerts-panel-tabs .tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
}

.alerts-panel-tabs .tab-btn:hover {
    background: #e9ecef;
}

.alerts-panel-tabs .tab-btn.active {
    background: white;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
}

.alerts-panel-tabs .tab-btn .badge {
    margin-left: 8px;
    padding: 2px 8px;
    background: #95a5a6;
    color: white;
    border-radius: 10px;
    font-size: 12px;
}

.alerts-panel-content {
    flex: 1;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

.tab-content {
    display: none;
    padding: 15px;
}

.tab-content.active {
    display: block;
}

.alerts-filter,
.insights-filter {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
}

.alerts-filter label {
    margin-right: 15px;
    font-size: 13px;
}

.alerts-list,
.insights-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alert-item,
.insight-item {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    transition: all 0.3s, background-color 0.3s, border-color 0.3s;
}

.alert-item:hover,
.insight-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.alert-item.severity-critical {
    border-left: 4px solid #e74c3c;
    background: #fff5f5;
}

.alert-item.severity-warning {
    border-left: 4px solid #f39c12;
    background: #fffbf5;
}

.alert-item.severity-info {
    border-left: 4px solid #3498db;
    background: #f5f9ff;
}

.alert-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.alert-icon {
    font-size: 16px;
}

.alert-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
}

.btn-acknowledge {
    padding: 4px 8px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
}

.btn-acknowledge:hover {
    background: #229954;
}

.alert-message {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
    line-height: 1.4;
}

.alert-meta,
.insight-meta {
    display: flex;
    gap: 10px;
    font-size: 11px;
    color: #999;
    flex-wrap: wrap;
}

.alert-node,
.insight-node {
    font-weight: 600;
    color: #3498db;
}

.alert-metadata {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
}

.meta-item {
    padding: 2px 8px;
    background: #ecf0f1;
    border-radius: 3px;
    color: #555;
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.insight-icon {
    font-size: 16px;
}

.insight-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
}

.insight-confidence {
    padding: 2px 6px;
    background: #3498db;
    color: white;
    border-radius: 3px;
    font-size: 11px;
}

.insight-description {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
    line-height: 1.4;
}

.insight-category {
    padding: 2px 8px;
    background: #ecf0f1;
    border-radius: 3px;
    text-transform: uppercase;
    font-weight: 600;
    color: #555;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
    font-size: 14px;
}

/* Dark mode for Alerts Panel */
@media (prefers-color-scheme: dark) {
    .alert-badge .btn-icon {
        background: #343a40;
        border-color: #495057;
        color: #e0e0e0;
    }

    .alert-badge .btn-icon:hover {
        background: #495057;
    }

    .alerts-panel {
        background: #1e1e1e;
        border-color: #444;
        box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    }

    .alerts-panel-header {
        background: #2a2a2a;
        border-bottom-color: #444;
    }

    .alerts-panel-header .btn-icon {
        color: #e0e0e0;
    }

    .alerts-panel-header .btn-icon:hover {
        opacity: 1;
        color: #fff;
    }

    .alerts-panel-tabs {
        background: #252525;
        border-bottom-color: #444;
    }

    .alerts-panel-tabs .tab-btn {
        color: #aaa;
    }

    .alerts-panel-tabs .tab-btn:hover {
        background: #333;
    }

    .alerts-panel-tabs .tab-btn.active {
        background: #1e1e1e;
        color: #4dabf7;
        border-bottom-color: #4dabf7;
    }

    .alerts-panel-tabs .tab-btn .badge {
        background: #555;
    }

    .alerts-filter label,
    .insights-filter {
        color: #e0e0e0;
    }

    .insights-filter {
        border-bottom-color: #444;
    }

    .alert-item,
    .insight-item {
        background: #252525;
        border-color: #444;
    }

    .alert-item:hover,
    .insight-item:hover {
        box-shadow: 0 2px 8px rgba(255,255,255,0.1);
    }

    .alert-item.severity-critical {
        background: #2d1a1a;
        border-left-color: #ef4444;
    }

    .alert-item.severity-warning {
        background: #2d2514;
        border-left-color: #f59e0b;
    }

    .alert-item.severity-info {
        background: #1a2534;
        border-left-color: #3b82f6;
    }

    .alert-title,
    .insight-title {
        color: #e0e0e0;
    }

    .alert-message,
    .insight-description {
        color: #bbb;
    }

    .alert-meta,
    .insight-meta {
        color: #777;
    }

    .alert-node,
    .insight-node {
        color: #4dabf7;
    }

    .meta-item,
    .insight-category {
        background: #333;
        color: #aaa;
    }

    .btn-acknowledge {
        background: #27ae60;
    }

    .btn-acknowledge:hover {
        background: #2ecc71;
    }

    .empty-state {
        color: #666;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .alerts-panel {
        width: 90vw;
        max-width: 400px;
        right: 5vw;
    }
}

/* Phase 6: Financial Earnings Styles */

.earnings-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 25px;
    width: 100%;
}

.earnings-stat {
    text-align: center;
    padding: 10px;
}

.earnings-stat-value {
    font-size: 1.8em;
    font-weight: bold;
    color: #22c55e;
    margin-bottom: 5px;
}

.earnings-breakdown {
    margin-bottom: 25px;
    clear: both;
}

.earnings-breakdown h5 {
    margin-bottom: 12px;
    font-size: 1em;
}

.earnings-breakdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.breakdown-label {
    min-width: 80px;
    font-weight: 500;
    font-size: 0.95em;
}

.breakdown-bar {
    flex: 1;
    height: 24px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    min-width: 100px;
}

.breakdown-fill {
    height: 100%;
    display: block;
    transition: width 0.3s ease;
}

.breakdown-fill.egress-fill {
    background: #0ea5e9;
}

.breakdown-fill.storage-fill {
    background: #22c55e;
}

.breakdown-fill.repair-fill {
    background: #f59e0b;
}

.breakdown-fill.audit-fill {
    background: #a855f7;
}

.breakdown-amount {
    min-width: 70px;
    text-align: right;
    font-weight: 600;
}

.breakdown-percent {
    min-width: 50px;
    text-align: right;
    color: #888;
    font-size: 0.9em;
}

.satellite-earnings {
    margin-bottom: 25px;
    clear: both;
}

.satellite-earnings h5 {
    margin-bottom: 12px;
    font-size: 1em;
}

.satellite-earnings-item {
    padding: 12px;
    margin-bottom: 10px;
    border-left: 4px solid #0ea5e9;
    background: #f8f9fa;
    border-radius: 4px;
}

.satellite-earnings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.satellite-earnings-total {
    font-size: 1.2em;
    font-weight: bold;
    color: #22c55e;
}

.satellite-earnings-details {
    font-size: 0.9em;
    color: #666;
}

#satellite-earnings-list {
    min-height: 60px;
}

/* Responsive layout for earnings summary */
@media (max-width: 1200px) {
    .earnings-summary {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .earnings-summary {
        grid-template-columns: 1fr;
    }
    
    .breakdown-label {
        min-width: 60px;
    }
    
    .breakdown-amount {
        min-width: 60px;
    }
}

/* Dark mode for earnings card */
@media (prefers-color-scheme: dark) {
    .earnings-stat-value {
        color: #34d399;
    }
    
    .breakdown-bar {
        background: #333;
    }
    
    .breakdown-percent {
        color: #888;
    }
    
    .satellite-earnings-item {
        background: #2a2a2a;
        border-left-color: #4dabf7;
    }
    
    .satellite-earnings-total {
        color: #34d399;
    }
    
    .satellite-earnings-details {
        color: #aaa;
    }
}


.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 8px;
    transition: opacity 0.3s ease-in-out;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-overlay p {
    color: #333;
    font-weight: 500;
}

.loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

/* Dark mode for loading indicator */
@media (prefers-color-scheme: dark) {
    .loading-overlay {
        background: rgba(30, 30, 30, 0.7);
    }

    .loading-overlay p {
        color: #e0e0e0;
    }

    .loader {
        border: 4px solid #444;
        border-top: 4px solid #4dabf7;
    }
}

/* ROI Calculator Inputs - Dark Mode Support */
.roi-input {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 1em;
    box-sizing: border-box;
}

.roi-input::placeholder {
    color: #999;
}

.roi-input:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.1);
}

@media (prefers-color-scheme: dark) {
    .roi-input {
        border-color: #444 !important;
        background: #2a2a2a !important;
        color: #e0e0e0 !important;
    }
    
    .roi-input::placeholder {
        color: #666 !important;
    }
    
    .roi-input:focus {
        border-color: #4dabf7 !important;
        box-shadow: 0 0 0 2px rgba(77, 171, 247, 0.1) !important;
    }
}

/* Phase 9: Multi-Node Comparison Styles */
#comparison-card {
    grid-column: 1 / -1;
}

.header-btn {
    padding: 8px 16px;
    background: #0ea5e9;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: background 0.2s;
}

.header-btn:hover {
    background: #0284c7;
}

.header-btn:active {
    background: #0369a1;
    transform: scale(0.98);
}

.header-btn:focus {
    outline: none;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2em;
    color: #888;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.comparison-selector {
    padding: 20px;
    background: rgba(14, 165, 233, 0.05);
    border-radius: 8px;
    margin-bottom: 20px;
}

.selector-group {
    margin-bottom: 15px;
}

.selector-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary, #333);
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.node-checkbox-item {
    display: grid;
    grid-template-columns: 18px 1fr;
    align-items: center;
    column-gap: 8px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 28px;
}

.node-checkbox-item:hover {
    background: #f8f9fa;
    border-color: #0ea5e9;
}

.node-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0; /* grid handles spacing */
    cursor: pointer;
    align-self: center;
    justify-self: start;
    accent-color: #0ea5e9; /* better visual consistency */
}
.node-checkbox-item label {
    display: inline-flex;
    align-items: center;
    line-height: 1.2;
    cursor: pointer;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comparison-select {
    width: 100%;
    padding: 8px 36px 8px 12px; /* space for custom arrow */
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    color: #333;
    font-size: 1em;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;           /* remove native gloss/reflection */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px 8px;
    box-shadow: none;
}
.comparison-select:focus {
    outline: none;
    border-color: #0ea5e9;
    box-shadow: 0 0 0 2px rgba(14,165,233,0.12);
}

.primary-btn {
    width: 100%;
    padding: 12px;
    background: #0ea5e9;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover:not(:disabled) {
    background: #0284c7;
}

.primary-btn:disabled {
    background: #888;
    cursor: not-allowed;
    opacity: 0.6;
}

.comparison-summary {
    margin: 20px 0;
}

.comparison-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.comparison-card-item {
    padding: 15px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
}

.comparison-card-item.winner {
    border-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.comparison-card-item .winner-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #22c55e;
    color: white;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    margin-bottom: 8px;
}

.comparison-table-container {
    margin: 20px 0;
    overflow-x: auto;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.comparison-table th,
.comparison-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.comparison-table th {
    background: #f8f9fa;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.comparison-table td {
    background: #fff;
}

.comparison-table .rank-1 {
    background: rgba(34, 197, 94, 0.1);
    font-weight: 600;
}

.comparison-table .rank-2 {
    background: rgba(14, 165, 233, 0.05);
}

.comparison-table .rank-last {
    background: rgba(239, 68, 68, 0.05);
}

.comparison-charts {
    margin: 20px 0;
}

.export-btn {
    padding: 8px 16px;
    background: #0ea5e9;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.export-btn:hover {
    background: #0284c7;
}

/* Dark mode for comparison */
@media (prefers-color-scheme: dark) {
    .header-btn {
        background: #4dabf7;
    }
    
    .header-btn:hover {
        background: #339af0;
    }
    
    .close-btn:hover {
        color: #fff;
    }
    
    .comparison-selector {
        background: rgba(14, 165, 233, 0.1);
    }
    
    .selector-group label {
        color: #e0e0e0;
    }
    
    .node-checkbox-item {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .node-checkbox-item:hover {
        background: #333;
        border-color: #4dabf7;
    }
    
    .comparison-select {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        padding-right: 36px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23bbb' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        background-size: 12px 8px;
        box-shadow: none;
    }
    
    .primary-btn {
        background: #4dabf7;
    }
    
    .primary-btn:hover:not(:disabled) {
        background: #339af0;
    }
    
    .comparison-card-item {
        background: #2a2a2a;
        border-color: #444;
    }
    
    .comparison-card-item.winner {
        border-color: #34d399;
        background: rgba(34, 197, 94, 0.15);
    }
    
    .comparison-card-item .winner-badge {
        background: #34d399;
        color: #121212;
    }
    
    .comparison-table th {
        background: #2a2a2a;
    }
    
    .comparison-table th,
    .comparison-table td {
        border-bottom-color: #444;
    }
    
    .comparison-table td {
        background: #1e1e1e;
    }
    
    .comparison-table .rank-1 {
        background: rgba(34, 197, 94, 0.15);
    }
    
    .comparison-table .rank-2 {
        background: rgba(14, 165, 233, 0.1);
    }
    
    .comparison-table .rank-last {
        background: rgba(239, 68, 68, 0.1);
    }
    
    .export-btn {
        background: #4dabf7;
    }
    
    .export-btn:hover {
        background: #339af0;
    }
}
