* {
    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, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: #f8f9fa;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

header h1 {
    font-size: 24px;
    font-weight: 600;
}

.auth-section {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

#adminKeyInput {
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    min-width: 250px;
    background: rgba(255, 255, 255, 0.9);
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#loginBtn, #logoutBtn {
    background: #e94560;
    color: white;
}

#loginBtn:hover, #logoutBtn:hover {
    background: #d63d56;
}

.refresh-btn {
    background: #0f3460;
    color: white;
}

.refresh-btn:hover {
    background: #16213e;
}

#authStatus {
    font-size: 12px;
    opacity: 0.9;
}

main {
    padding: 0;
}

.login-prompt {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    font-size: 18px;
}

/* Tabs Navigation */
.tabs {
    display: flex;
    background: #0f3460;
    padding: 0;
    gap: 0;
    overflow-x: auto;
}

.tab-btn {
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    padding: 15px 25px;
    border-radius: 0;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transform: none;
    box-shadow: none;
}

.tab-btn.active {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-bottom-color: #e94560;
}

/* Tab Content */
.tab-content {
    display: none;
    padding: 30px;
}

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-header h2 {
    color: #16213e;
    font-size: 20px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #e94560;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #16213e;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Forms */
.actions {
    margin-bottom: 30px;
    padding: 25px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.actions h2 {
    margin-bottom: 20px;
    color: #16213e;
    font-size: 18px;
}

.form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: #555;
    font-size: 14px;
}

.form-group input,
.form-group select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #0f3460;
}

.form-group input[readonly] {
    background: #f8f9fa;
    cursor: default;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

.input-with-button button {
    padding: 8px 12px;
    background: #f0f0f0;
    border: 2px solid #e0e0e0;
    font-size: 16px;
    min-width: 42px;
}

.input-with-button button:hover {
    background: #e0e0e0;
}

.form button[type="submit"] {
    background: #e94560;
    color: white;
    padding: 12px 30px;
    height: fit-content;
}

.form button[type="submit"]:hover {
    background: #d63d56;
}

/* Tables */
.keys-list {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.keys-list h2 {
    color: #16213e;
    font-size: 18px;
}

.keys-header {
    display: flex;
    gap: 15px;
    align-items: center;
}

#keysCount {
    color: #666;
    font-size: 14px;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: white;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: #f8f9fa;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #16213e;
    border-bottom: 2px solid #e0e0e0;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

tbody tr:hover {
    background: #f8f9fa;
}

.loading {
    text-align: center;
    color: #999;
    padding: 40px !important;
}

.delete-btn {
    background: #dc3545;
    color: white;
    padding: 6px 12px;
    font-size: 12px;
}

.delete-btn:hover {
    background: #c82333;
}

.delete-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Badges */
.role-badge, .status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.user {
    background: #e3f2fd;
    color: #1976d2;
}

.role-badge.observer {
    background: #f3e5f5;
    color: #7b1fa2;
}

.role-badge.validator {
    background: #fff3e0;
    color: #e65100;
}

.role-badge.miner {
    background: #e8f5e9;
    color: #388e3c;
}

.role-badge.admin {
    background: #ffebee;
    color: #c62828;
}

.status-badge.active, .status-badge.healthy {
    background: #e8f5e9;
    color: #388e3c;
}

.status-badge.inactive, .status-badge.unhealthy {
    background: #ffebee;
    color: #c62828;
}

.status-badge.unknown {
    background: #fff3e0;
    color: #e65100;
}

/* ID/Key display */
.id-display {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    background: #f5f5f5;
    padding: 4px 8px;
    border-radius: 4px;
    word-break: break-all;
    max-width: 200px;
    display: inline-block;
}

.id-display.truncate {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Messages */
.message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateX(400px);
    transition: transform 0.3s;
    z-index: 1000;
}

.message.show {
    transform: translateX(0);
}

.message.success {
    background: #4caf50;
    color: white;
}

.message.error {
    background: #f44336;
    color: white;
}

.message.info {
    background: #2196f3;
    color: white;
}

/* Category Sections */
.category-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

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

.category-header h2 {
    margin: 0;
    font-size: 20px;
    color: #16213e;
}

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

.category-badge {
    background: #e0e0e0;
    color: #666;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.category-header.aggregator .category-badge {
    background: #e3f2fd;
    color: #1976d2;
}

.category-header.subnet .category-badge {
    background: #e8f5e9;
    color: #388e3c;
}

.category-desc {
    color: #666;
    font-size: 14px;
    margin-bottom: 20px;
    padding-left: 36px;
}

/* Subnet Info */
.subnet-info {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
    align-items: center;
}

.subnet-info .info-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.subnet-info .info-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subnet-info .info-value {
    font-size: 18px;
    font-weight: 600;
    color: #2e7d32;
}

.subnet-info.error {
    background: linear-gradient(135deg, #ffebee 0%, #ffcdd2 100%);
}

.subnet-info.error .info-value {
    color: #c62828;
}

/* Logs Panel */
.logs-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.logs-controls select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.auto-scroll-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
}

.auto-scroll-label input {
    cursor: pointer;
}

.clear-btn {
    background: #dc3545;
    color: white;
}

.clear-btn:hover {
    background: #c82333;
}

.logs-info {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
    font-size: 13px;
    color: #666;
}

.logs-container {
    background: #1e1e1e;
    border-radius: 8px;
    overflow: hidden;
    height: 500px;
    position: relative;
}

.logs-content {
    height: 100%;
    overflow-y: auto;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-timestamp {
    color: #6a9955;
    white-space: nowrap;
    flex-shrink: 0;
}

.log-level {
    font-weight: bold;
    width: 50px;
    text-align: center;
    flex-shrink: 0;
    padding: 1px 4px;
    border-radius: 3px;
}

.log-level.ERROR {
    color: #f44336;
    background: rgba(244, 67, 54, 0.2);
}

.log-level.WARN {
    color: #ff9800;
    background: rgba(255, 152, 0, 0.2);
}

.log-level.INFO {
    color: #4fc3f7;
    background: rgba(79, 195, 247, 0.2);
}

.log-level.DEBUG {
    color: #9e9e9e;
    background: rgba(158, 158, 158, 0.2);
}

.log-level.TRACE {
    color: #616161;
    background: rgba(97, 97, 97, 0.2);
}

.log-target {
    color: #ce9178;
    flex-shrink: 0;
}

.log-message {
    color: #d4d4d4;
    word-break: break-word;
    flex: 1;
}

.logs-empty {
    color: #666;
    text-align: center;
    padding: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        text-align: center;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        flex: 1;
        min-width: 100px;
        text-align: center;
    }
    
    .section-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .id-display {
        max-width: 100px;
    }
    
    .logs-container {
        height: 400px;
    }
    
    .logs-controls {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Error Notice for Subnet Data */
.error-notice {
    background: linear-gradient(135deg, #ff6b35 0%, #f72585 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.error-notice strong {
    display: block;
    font-size: 16px;
    margin-bottom: 10px;
}

.error-notice p {
    font-size: 14px;
    opacity: 0.95;
}
