/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Light Theme Colors */
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary-color: #64748b;
    --accent-color: #06d6a0;
    --background: #ffffff;
    --surface: #f8fafc;
    --surface-hover: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: rgba(15, 23, 42, 0.08);
    --shadow-lg: rgba(15, 23, 42, 0.15);
}

[data-theme="dark"] {
    /* Dark Theme Colors */
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --secondary-color: #94a3b8;
    --accent-color: #06d6a0;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: #334155;
    --border-light: #475569;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --shadow: rgba(0, 0, 0, 0.25);
    --shadow-lg: rgba(0, 0, 0, 0.35);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    transition: all 0.3s ease;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    position: relative;
    overflow: hidden;
}

.background-pattern {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    background: var(--background);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.brand-section {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    color: white;
    font-size: 1.5rem;
}

.brand-section h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.auth-tabs {
    display: flex;
    background: var(--surface);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 1.5rem;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn.active {
    background: white;
    color: var(--text-primary);
    box-shadow: 0 1px 3px var(--shadow);
}

.tab-btn:hover:not(.active) {
    color: var(--text-primary);
    background: var(--surface-hover);
}

.auth-forms {
    position: relative;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-secondary);
    z-index: 1;
}

.input-wrapper input {
    width: 100%;
    padding: 0.875rem 3rem 0.875rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--background);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.toggle-visibility {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    min-height: 2rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toggle-visibility:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.login-btn {
    width: 100%;
    padding: 0.875rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.help-section {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

.help-section p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.help-section a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

/* Dashboard Styles */
.dashboard-body {
    min-height: 100vh;
    background: var(--surface);
}

.main-content {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-content.full-width {
    margin-left: 0;
}

.top-header {
    background: var(--background);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px var(--shadow);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-brand .logo {
    width: 3rem;
    height: 3rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
}

.brand-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.theme-toggle {
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.theme-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.notification-btn {
    position: relative;
    background: none;
    border: none;
    font-size: 1.1rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--error);
    color: white;
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 10px;
    min-width: 1.2rem;
    text-align: center;
}

.user-info {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.user-info:hover {
    background: var(--surface);
}

.user-chevron {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
    transition: transform 0.2s ease;
}

.user-info.active .user-chevron {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 180px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.user-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.user-dropdown-item:hover {
    background: var(--surface);
}

.user-dropdown-item i {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.user-dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 0.5rem 0;
}

.logout-item {
    color: var(--error);
}

.logout-item:hover {
    background: rgba(239, 68, 68, 0.1);
}

.logout-item i {
    color: var(--error);
}

.user-avatar {
    width: 2rem;
    height: 2rem;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
}

.user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.dashboard-main {
    flex: 1;
    padding: 1.5rem;
}

.welcome-section {
    margin-bottom: 2rem;
}

.welcome-section h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.welcome-section p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
}

.stat-icon.requests { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.tokens { background: linear-gradient(135deg, #06d6a0, #059669); }
.stat-icon.success { background: linear-gradient(135deg, #10b981, #047857); }
.stat-icon.cost { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.models { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-icon.endpoints { background: linear-gradient(135deg, #ef4444, #dc2626); }

.stat-content {
    flex: 1;
}

.stat-content h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-change {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.negative {
    color: var(--error);
}

.usage-bar {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.usage-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning));
    transition: width 0.3s ease;
}

.charts-section {
    margin-bottom: 2rem;
}

.chart-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.chart-card.large {
    min-height: 320px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.time-filters {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn.active,
.filter-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.chart-container {
    height: 250px;
    position: relative;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1rem;
}

.info-card {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
}

.view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.activity-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: white;
}

.activity-icon.success {
    background: var(--success);
}

.activity-icon.error {
    background: var(--error);
}

.activity-content {
    flex: 1;
}

.activity-content p {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.activity-content span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.activity-status {
    padding: 0.25rem 0.5rem;
    background: var(--success);
    color: white;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.activity-status.error {
    background: var(--error);
}


/* Responsive Design */
@media (max-width: 768px) {
    .top-header {
        padding: 1rem;
    }
    
    .header-brand {
        gap: 0.75rem;
    }
    
    .header-brand .logo {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
    
    .brand-info h1 {
        font-size: 1.25rem;
    }
    
    .brand-subtitle {
        font-size: 0.8rem;
    }
    
    .login-card {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .search-bar {
        max-width: 200px;
    }
    
    .header-actions {
        gap: 0.5rem;
    }
    
    .user-name {
        display: none;
    }
}

@media (max-width: 480px) {
    .dashboard-main {
        padding: 1rem;
    }
    
    .top-header {
        padding: 1rem;
    }
    
    .welcome-section h1 {
        font-size: 1.5rem;
    }
    
    .chart-card {
        padding: 1rem;
    }
    
    .info-card {
        padding: 1rem;
    }
    
    .input-wrapper input {
        padding: 0.875rem 2.5rem 0.875rem 2.5rem;
        font-size: 0.9rem;
    }
    
    .toggle-visibility {
        right: 0.5rem;
        min-width: 1.75rem;
        min-height: 1.75rem;
        padding: 0.375rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

.slide-in-left {
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Loading States */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Relay Service Specific Styles */
.usage-text {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: block;
}

.stat-detail {
    color: var(--text-secondary);
    font-size: 0.75rem;
    display: block;
    margin-top: 0.25rem;
}

.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.no-data, .error-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.error-state {
    color: var(--error);
}

.model-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
}

.model-item:last-child {
    border-bottom: none;
}

.model-info {
    flex: 1;
    min-width: 0;
}

.model-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.model-details {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.model-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 80px;
}

.model-percentage {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 35px;
    text-align: right;
}

.model-bar {
    width: 60px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.model-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
    border-radius: 2px;
}

.error-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.error-stat {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.error-stat:hover {
    background: var(--surface-hover);
}

.error-code {
    width: 3rem;
    height: 3rem;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    background: var(--error);
}

.error-code.rate-limit {
    background: var(--warning);
}

.error-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.error-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.error-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.activity-details {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

/* Analytics Section Styles */
.analytics-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

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

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.analytics-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.time-range-filters {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.analytics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}


.metric {
    text-align: center;
    min-width: 80px;
}

.metric-value {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.cost-summary {
    display: flex;
    gap: 2rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.cost-current, .cost-projected {
    flex: 1;
}

.cost-current h4, .cost-projected h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.cost-amount {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.cost-change {
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cost-change.positive { color: var(--success); }
.cost-change.negative { color: var(--error); }

.cost-budget {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-light);
}

.cost-item:last-child {
    border-bottom: none;
}

.cost-service {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.cost-value {
    font-weight: 600;
    color: var(--text-primary);
}

.error-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.error-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 6px;
}

.error-code {
    width: 3rem;
    height: 3rem;
    border-radius: 6px;
    background: var(--error);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.error-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.error-message {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

.error-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.error-trend-icon { color: var(--error); }
.success-trend-icon { color: var(--success); }
.neutral-trend-icon { color: var(--text-secondary); }

.status-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.legend-color {
    width: 1rem;
    height: 0.5rem;
    border-radius: 2px;
}

.legend-color.success { background: #10b981; }
.legend-color.warning { background: #f59e0b; }
.legend-color.error { background: #ef4444; }

.metric-summary {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.current-metric {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.info-tooltip {
    color: var(--text-secondary);
    cursor: help;
    position: relative;
}

.info-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    top: -2rem;
    right: 0;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 100;
}

.export-btn {
    padding: 0.5rem 1rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.export-btn:hover {
    background: #059669;
    transform: translateY(-1px);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--background);
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.date-inputs {
    display: flex;
    gap: 1rem;
}

.date-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.date-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.date-input {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.export-format, .export-data {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.export-format h4, .export-data h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.export-format label, .export-data label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
}

/* Quota Card Styles */
.quota-card {
    position: relative;
}

.quota-refresh {
    color: var(--text-secondary);
    cursor: help;
    font-size: 1rem;
}

.quota-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quota-summary {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.quota-used, .quota-remaining {
    text-align: center;
    flex: 1;
}

.quota-number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.quota-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.quota-progress {
    margin-bottom: 1rem;
}

.quota-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.quota-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning));
    transition: width 0.3s ease;
    border-radius: 4px;
}

.quota-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.quota-percentage {
    font-weight: 600;
    color: var(--text-primary);
}

.quota-limit {
    color: var(--text-secondary);
}

.quota-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
}

.quota-time, .quota-trend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
}

.trend-positive {
    color: var(--success);
}

.trend-negative {
    color: var(--error);
}

/* Model Usage Card Styles */
.model-usage-card {
    position: relative;
}

.usage-period {
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.model-usage-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.model-usage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.model-name {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 100px;
    font-size: 0.9rem;
}

.model-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.model-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.model-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.model-percentage {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 35px;
    text-align: right;
}

.model-requests {
    font-size: 0.8rem;
    color: var(--text-secondary);
    min-width: 80px;
    text-align: right;
}

/* Usage Trend Card Styles */
.usage-trend-card {
    position: relative;
}

.trend-filters {
    display: flex;
    gap: 0.5rem;
}

.trend-filter {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.trend-filter.active,
.trend-filter:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.usage-trend-display {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.trend-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.trend-metric {
    text-align: center;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 6px;
}

.trend-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.trend-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.trend-change {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.trend-change.positive {
    color: var(--success);
}

.trend-change.negative {
    color: var(--error);
}

.trend-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.trend-chart-container {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: 6px;
    padding: 1rem;
}

.trend-insights {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.insight-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--surface);
    border-radius: 6px;
}

.insight-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: white;
}

.insight-icon.success {
    background: var(--success);
}

.insight-icon.info {
    background: var(--primary-color);
}

.insight-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.insight-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.insight-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Enhanced responsive design for relay service */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }
    
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .quota-summary {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1rem;
    }
    
    .quota-details {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .model-usage-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .model-stats {
        width: 100%;
        justify-content: space-between;
    }
    
    .trend-summary {
        grid-template-columns: 1fr;
    }
    
    .trend-filters {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    
    .insight-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        text-align: left;
    }
    
    .analytics-section {
        margin-top: 2rem;
        padding-top: 1.5rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .analytics-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        width: 100%;
    }
    
    .time-range-filters {
        width: 100%;
        justify-content: flex-start;
    }
    
    
    .cost-summary {
        flex-direction: column;
        gap: 1rem;
    }
    
    .date-inputs {
        flex-direction: column;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .export-btn {
        width: 100%;
        justify-content: center;
    }
    
    .model-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .model-stats {
        align-self: stretch;
        justify-content: space-between;
    }
    
    .error-stat {
        padding: 0.5rem;
    }
    
    .error-code {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 0.75rem;
    }
}

/* Animations for relay service elements */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Quota Usage Combined Card Styles */
.quota-usage-combined-card {
  position: relative;
}

.quota-usage-combined {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.quota-section {
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 1.5rem;
}

.usage-trend-section {
  padding-top: 0.5rem;
}

.usage-trend-section .section-title {
  margin-bottom: 1rem;
}

.usage-trend-section .section-title h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.quota-usage-combined-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.quota-usage-combined-card .trend-filters {
  display: flex;
  gap: 0.5rem;
}

/* Responsive design for combined card */
@media (max-width: 768px) {
  .quota-usage-combined {
    gap: 1.5rem;
  }
  
  .quota-section {
    padding-bottom: 1rem;
  }
  
  .quota-usage-combined-card .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  
  .quota-usage-combined-card .trend-filters {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 480px) {
  .quota-usage-combined {
    gap: 1rem;
  }
  
  .usage-trend-section .section-title h4 {
    font-size: 0.9rem;
  }
}

/* Mirror Site Status Styles */
.mirror-status-card {
  position: relative;
}

.refresh-all-btn {
  padding: 0.5rem 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.refresh-all-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.refresh-all-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.mirror-status-display {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mirror-status-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.mirror-status-item:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px var(--shadow);
}

.site-info {
  flex: 1;
  min-width: 0;
}

.site-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.site-url {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

.status-history {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}

.history-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-dots {
  display: flex;
  gap: 0.25rem;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  cursor: help;
  transition: all 0.2s ease;
  position: relative;
}

.status-dot:hover {
  transform: scale(1.2);
}

.status-dot.operational {
  background: var(--success);
}

.status-dot.degraded {
  background: var(--warning);
}

.status-dot.offline {
  background: var(--error);
}

.current-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 120px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.status-indicator.operational {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.status-indicator.degraded {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.status-indicator.offline {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.status-indicator.checking {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
}

.status-indicator i {
  font-size: 0.7rem;
}

.latency-display {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}

.ping-btn {
  padding: 0.5rem 1rem;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.ping-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.ping-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.status-updated {
  text-align: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Responsive design for mirror status */
@media (max-width: 768px) {
  .mirror-status-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .site-info {
    width: 100%;
  }

  .status-history {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-width: auto;
  }

  .history-label {
    margin-bottom: 0;
  }

  .current-status {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-width: auto;
  }

  .ping-btn {
    width: 100%;
    margin-top: 0.5rem;
  }
}

@media (max-width: 480px) {
  .mirror-status-item {
    padding: 0.75rem;
  }

  .status-dots {
    gap: 0.2rem;
  }

  .status-dot {
    width: 10px;
    height: 10px;
  }

  .refresh-all-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .current-status {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Status indicator animations */
@keyframes pulse-success {
  0%, 100% { background: rgba(16, 185, 129, 0.1); }
  50% { background: rgba(16, 185, 129, 0.2); }
}

@keyframes pulse-warning {
  0%, 100% { background: rgba(245, 158, 11, 0.1); }
  50% { background: rgba(245, 158, 11, 0.2); }
}

@keyframes pulse-error {
  0%, 100% { background: rgba(239, 68, 68, 0.1); }
  50% { background: rgba(239, 68, 68, 0.2); }
}

.status-indicator.operational {
  animation: pulse-success 3s infinite;
}

.status-indicator.degraded {
  animation: pulse-warning 2s infinite;
}

.status-indicator.offline {
  animation: pulse-error 1.5s infinite;
}

/* Tooltip styles for status dots */
.status-dot[title]:hover::after {
  content: attr(title);
  position: absolute;
  top: -2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
}