:root {
    --glass-bg: rgba(30, 30, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    --primary-color: #0A84FF;
    --text-color: #f5f5f7;
    --text-secondary: #86868b;
    --danger-color: #ff453a;
    --success-color: #32d74b;
    --card-radius: 24px;
    --input-bg: rgba(255, 255, 255, 0.1);
    --input-border: rgba(255, 255, 255, 0.2);
    --input-focus: rgba(255, 255, 255, 0.2);
}

body {
    margin: 0;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* Deep Dark Space Gradient */
    background: linear-gradient(135deg, #0f2027 0%, #203a43 50%, #2c5364 100%);
    background-attachment: fixed;
    color: var(--text-color);
    min-height: 100vh;
    box-sizing: border-box;
}

/* Animated Mesh Gradient Background - Darker */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 10%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 10%, 1) 0, transparent 50%);
    background:
        radial-gradient(circle at 15% 50%, rgba(10, 132, 255, 0.15), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(48, 209, 88, 0.1), transparent 25%);
    z-index: -1;
}

h1,
h2,
h3 {
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-top: 0;
    color: #fff;
}

h1 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 40px;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.main-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Glass Card Style - Dark */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    box-shadow: var(--glass-shadow);
    padding: 30px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.6);
}

/* Connect Section */
.connect-container {
    align-self: center;
    width: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

form#connectForm {
    display: flex;
    gap: 15px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: center;
}

input,
select,
button {
    font-family: inherit;
    font-size: 1rem;
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid var(--input-border);
    outline: none;
    transition: all 0.2s;
}

input,
select {
    background: var(--input-bg);
    color: #fff;
    flex: 1;
    min-width: 150px;
}

input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

input:focus,
select:focus {
    background: var(--input-focus);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(10, 132, 255, 0.3);
}

select option {
    background: #2c2c2e;
    color: #fff;
}

button {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
    cursor: pointer;
    border: none;
    min-width: 120px;
}

button:hover {
    background: #0071e3;
    transform: scale(1.02);
}

/* Stats Grid - Layout Change */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    /* Prevent stretching to match height of tallest column */
}

/* First card (General Stats) spans full width */
.stats-grid .card:first-child {
    grid-column: 1 / -1;
    min-height: auto;
    /* Allow it to fit content */
}

.stats-grid .card {
    display: flex;
    flex-direction: column;
    height: auto;
    /* Remove fixed min-height */
    padding: 20px;
    /* Reduce padding slightly */
}

.stats-grid h2 {
    font-size: 1.2rem;
    /* Reduce font size */
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    color: #fff;
}

/* Charts */
.chart-container {
    position: relative;
    width: 100%;
    height: 300px;
    /* Fixed height for charts */
    min-height: 300px;
}

/* Logs List - Dark */
ul[id$="last-api-requests"] {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    /* Darker background for list */
    border-radius: 12px;
    padding: 10px;
}

ul[id$="last-api-requests"] li {
    font-size: 0.85rem;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
}

ul[id$="last-api-requests"] li:last-child {
    border-bottom: none;
}

ul[id$="last-api-requests"] li.error {
    color: var(--danger-color);
    background: rgba(255, 69, 58, 0.15);
    /* Adjusted for dark mode visibility */
    border-radius: 6px;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Mobile Responsive */
@media (max-width: 900px) {
    .stats-grid {
        grid-template-columns: 1fr;
        /* Stack on smaller screens */
    }

    h1 {
        font-size: 2rem;
    }

    .card {
        padding: 20px;
    }
}