:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #1a1f35 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-icon {
    width: 36px;
    height: 36px;
    stroke: var(--primary-color);
    stroke-width: 2;
}

.health-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 20px;
    border: 1px solid var(--success-color);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s ease-in-out infinite;
}

.status-text {
    font-size: 14px;
    font-weight: 600;
    color: var(--success-color);
}

.health-status.degraded {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-color);
}

.health-status.degraded .status-dot {
    background: var(--danger-color);
}

.health-status.degraded .status-text {
    color: var(--danger-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card.full-width {
    grid-column: 1 / -1;
}

.card.chart-card {
    min-height: 350px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.card-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-icon {
    font-size: 24px;
}

.card-content {
    color: var(--text-secondary);
}

/* Stats Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* ElectrumX Grid Layout */
.electrumx-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.electrumx-grid .full-width {
    grid-column: 1 / -1;
}

.stat-item {
    padding: 16px;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.stat-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.stat-link:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    transform: translateY(-2px);
}

.stat-link::after {
    content: '→';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--primary-color);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-link:hover::after {
    opacity: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-word;
}

#activeServers {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
}

/* Resource Monitoring */
.resource-item {
    display: grid;
    grid-template-columns: 120px 1fr 80px;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.resource-item:last-child {
    margin-bottom: 0;
}

.resource-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.resource-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    text-align: right;
}

.progress-bar {
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 4px;
    transition: width 0.5s ease;
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Table */
.table-container {
    overflow-x: auto;
}

.blocks-table {
    width: 100%;
    border-collapse: collapse;
}

.blocks-table thead {
    background: rgba(99, 102, 241, 0.1);
}

.blocks-table th {
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
}

.blocks-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.blocks-table tbody tr {
    transition: background 0.2s;
}

.blocks-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.blocks-table .hash-cell {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--primary-color);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blocks-table .loading {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
}

.peer-addr {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.peer-inbound {
    padding: 4px 8px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: 4px;
    color: var(--success-color);
    font-size: 12px;
    font-weight: 600;
}

.peer-outbound {
    padding: 4px 8px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 4px;
    color: var(--primary-color);
    font-size: 12px;
    font-weight: 600;
}

/* Back Button */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.back-button:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: translateX(-4px);
}

/* Peers Table Specific */
.peers-table td {
    white-space: nowrap;
}

.peers-table .peer-addr {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: var(--text-primary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 14px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.footer p {
    margin: 4px 0;
}

#lastUpdate {
    color: var(--primary-color);
    font-weight: 600;
}

/* Chart Styling */
.chart-description {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.05);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    font-style: italic;
}

canvas {
    max-height: 280px !important;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .stat-grid-3col {
        grid-template-columns: 1fr;
    }

    .electrumx-grid {
        grid-template-columns: 1fr;
    }

    .resource-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .resource-value {
        text-align: left;
    }

    .blocks-table {
        font-size: 12px;
    }

    .blocks-table th,
    .blocks-table td {
        padding: 8px;
    }
}

/* Loading Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.5s ease-out;
}
