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

:root {
    /* Cores principais do tema dark */
    --primary-color: #00bfff;
    --primary-hover: #0099cc;
    --secondary-color: #64748b;
    --accent-orange: #ffa500;
    
    /* Backgrounds escuros */
    --background: #121212;
    --surface: #1e1e1e;
    --surface-elevated: #252525;
    
    /* Bordas e divisores */
    --border: #2a2a2a;
    --border-light: #333333;
    
    /* Textos */
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-muted: #707070;
    
    /* Estados */
    --success: #10b981;
    --danger: #ef4444;
    --warning: #ffa500;
    
    /* Dimensões */
    --sidebar-width: 280px;
    --header-height: 64px;
    
    /* Sombras para dark mode */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.7);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 100%;
    height: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 0 0 20px rgba(0, 191, 255, 0.3);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.database-selector {
    padding: 8px 16px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--surface-elevated);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    min-width: 200px;
    transition: all 0.3s ease;
}

.database-selector:hover {
    border-color: var(--primary-color);
    background: var(--surface);
}

.database-selector:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.1);
}

/* Main Container */
.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.sidebar-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.search-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 14px;
    background: var(--surface-elevated);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(0, 191, 255, 0.1);
}

.table-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.table-list li {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.table-list li:hover {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border-left: 3px solid var(--primary-color);
}

.table-list li.active {
    background: linear-gradient(90deg, rgba(0, 191, 255, 0.2) 0%, transparent 100%);
    color: var(--primary-color);
    border-left: 3px solid var(--primary-color);
    font-weight: 600;
}

.table-list li.empty-state {
    color: var(--text-muted);
    text-align: center;
    cursor: default;
}

.table-list li.empty-state:hover {
    background: transparent;
    border-left: none;
}

/* Content */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    padding: 16px 24px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    border-radius: 6px 6px 0 0;
}

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

.tab-btn.active {
    color: var(--primary-color);
    background: var(--background);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--background);
}

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

/* Dashboard */
.dashboard-grid {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border);
}

.card.full-width {
    width: 100%;
}

.card h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.minor-metrics {
    display: flex;
    grid-column-gap: 20px;
    grid-row-gap: 20px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--surface-elevated);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-orange) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.table-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.table-detail-card {
    padding: 16px;
    background: var(--surface-elevated);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
}

.table-detail-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.1);
}

.table-detail-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.table-detail-card .detail-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.table-detail-card .detail-row span:last-child {
    color: var(--accent-orange);
    font-weight: 600;
}

/* Data Viewer */
.data-viewer {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
}

.table-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-info h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-container {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    overflow: auto;
    max-height: 600px;
}

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

.data-table thead {
    position: sticky;
    top: 0;
    background: var(--surface-elevated);
    z-index: 10;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-light);
}

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

.data-table tbody tr {
    transition: all 0.2s ease;
}

.data-table tbody tr:hover {
    background: var(--surface-elevated);
}

.data-table .empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 48px;
}

.chart-section {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 24px;
}

.chart-section h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Chart Header */
.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-evenly;
}

.chart-controls {
    display: flex;
    gap: 8px;
}

#metricsComparisonChart {
    max-height: 400px;
}

/* Gauges Section */
.gauges-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.gauge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface-elevated);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.gauge-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.15);
}

.gauge-item canvas {
    max-width: 200px;
    max-height: 200px;
}

.gauge-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 16px;
}

.metric-chart-container {
    background: var(--surface-elevated);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    min-height: 300px;
    transition: all 0.3s ease;
}

.metric-chart-container:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.1);
}

.metric-chart-container canvas {
    max-height: 250px;
}

@media (max-width: 1024px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0099cc 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0, 191, 255, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0099cc 0%, var(--primary-color) 100%);
    box-shadow: 0 6px 16px rgba(0, 191, 255, 0.4);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 4px 8px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-orange) 100%);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 191, 255, 0.3);
}

/* Loading */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 18, 18, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(0, 191, 255, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--surface);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: var(--header-height);
        height: calc(100vh - var(--header-height));
        z-index: 90;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

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

    .data-header {
        flex-direction: column;
        gap: 12px;
    }
}

/* Animações suaves */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.card.geral {
    display: grid;
    align-items: baseline;
}

/* Glow effects */
.btn-primary,
.badge,
.stat-value {
    position: relative;
}

.btn-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    padding: 2px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-orange));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.btn-primary:hover::before {
    opacity: 0.5;
}