:root {
    --deep: #050914;
    --panel: rgba(12, 21, 38, 0.88);
    --border: rgba(148, 163, 184, 0.14);
    --text: #f4f7fb;
    --muted: #8fa1b8;
    --blue: #5ca5ff;
    --cyan: #37d8ff;
    --green: #4ade80;
    --amber: #fbbf24;
    --red: #fb7185;
    --orange: #fb923c;
}

* { box-sizing: border-box; }

html { background: var(--deep); }

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background-color: var(--deep);
    background-image:
        linear-gradient(120deg, rgba(4, 8, 18, 0.93), rgba(5, 12, 25, 0.84)),
        url("/static/games/backgrounds/default.svg");
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    content: "";
    opacity: 0.2;
    background-image:
        linear-gradient(rgba(96, 165, 250, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(96, 165, 250, 0.08) 1px, transparent 1px);
    background-size: 54px 54px;
    mask-image: linear-gradient(to bottom, black, transparent 82%);
}

button { font: inherit; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 3px;
}

main {
    width: min(1480px, 100%);
    margin: 0 auto;
    padding: 38px 28px 64px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    margin-bottom: 28px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.brand-mark {
    display: grid;
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    place-items: center;
    border: 1px solid rgba(92, 165, 255, 0.38);
    border-radius: 16px;
    background: linear-gradient(145deg,
        rgba(55, 216, 255, 0.2), rgba(79, 70, 229, 0.22));
    box-shadow: 0 12px 35px rgba(37, 99, 235, 0.18);
    font-size: 25px;
}

.eyebrow {
    margin: 0 0 5px;
    color: #93c5fd;
    font-size: 11px;
    font-weight: 750;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    font-size: clamp(27px, 3.5vw, 42px);
    line-height: 1.07;
    letter-spacing: -0.04em;
}

.subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.service-strip {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 9px;
}

.service-indicator,
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: rgba(7, 14, 28, 0.64);
    color: #c4cfdd;
    font-size: 12px;
    font-weight: 650;
    white-space: nowrap;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--amber);
    box-shadow: 0 0 12px currentColor;
}

.online {
    color: #9cf2ba;
    border-color: rgba(74, 222, 128, 0.24);
}
.online .status-dot { background: var(--green); }
.offline {
    color: #fda4af;
    border-color: rgba(251, 113, 133, 0.24);
}
.offline .status-dot { background: var(--red); }

.panel {
    border: 1px solid var(--border);
    border-radius: 22px;
    background: linear-gradient(145deg,
        rgba(18, 32, 55, 0.88), rgba(7, 14, 28, 0.9));
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(18px);
}

.payment-panel {
    display: grid;
    grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr);
    gap: 24px;
    align-items: center;
    margin-bottom: 24px;
    padding: 22px 25px;
    border-color: rgba(55, 216, 255, 0.22);
}
.payment-content { min-width: 0; }
.billing-summary { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
.billing-metric { padding: 12px 14px; border: 1px solid rgba(148, 163, 184, .14); border-radius: 12px; background: rgba(3, 9, 21, .52); color: #cbd5e1; font-size: 13px; }
.billing-remaining { border-color: rgba(55, 216, 255, .35); color: #baf5ff; font-weight: 800; }
.billing-complete { margin: 12px 0 0; color: var(--green); font-weight: 750; }
.payment-panel .account-link.primary { display: inline-flex; margin-top: 12px; }

.energy-panel {
    position: relative;
    margin-bottom: 34px;
    padding: 25px;
    overflow: hidden;
    border-color: rgba(96, 165, 250, 0.28);
}

.energy-panel::before {
    position: absolute;
    top: -180px;
    right: -80px;
    width: 430px;
    height: 430px;
    pointer-events: none;
    content: "";
    border-radius: 50%;
    background: rgba(37, 99, 235, 0.14);
    filter: blur(80px);
}

.section-heading {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 19px;
}

.section-heading h2 {
    margin: 0;
    font-size: clamp(19px, 2vw, 23px);
    letter-spacing: -0.025em;
}

.section-kicker {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.energy-summary {
    position: relative;
    display: grid;
    grid-template-columns: 1.3fr repeat(5, minmax(0, 1fr));
    gap: 11px;
}

.energy-metric {
    min-width: 0;
    min-height: 116px;
    padding: 15px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 15px;
    background: rgba(3, 9, 21, 0.5);
}

.energy-metric.primary {
    border-color: rgba(55, 216, 255, 0.2);
    background: linear-gradient(145deg,
        rgba(14, 116, 144, 0.22), rgba(30, 64, 175, 0.18));
}

.metric-label,
.label {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.energy-value {
    margin-top: 12px;
    color: #f8fbff;
    font-size: clamp(20px, 2.2vw, 29px);
    font-weight: 760;
    letter-spacing: -0.035em;
    white-space: nowrap;
}

.energy-metric.primary .energy-value {
    color: #dffaff;
    font-size: clamp(28px, 3vw, 38px);
}

.energy-subvalue {
    margin-top: 6px;
    overflow-wrap: anywhere;
    color: #93c5fd;
    font-size: 12px;
}

.chart-card {
    position: relative;
    margin-top: 14px;
    padding: 18px 18px 12px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 17px;
    background: rgba(2, 7, 18, 0.58);
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.chart-title {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.chart-caption {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 11px;
}

.range-switcher {
    display: flex;
    gap: 4px;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(9, 17, 31, 0.7);
}

.range-button {
    min-width: 54px;
    padding: 7px 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    transition: background-color 140ms ease, color 140ms ease;
}

.range-button:hover {
    color: var(--text);
    background: rgba(92, 165, 255, 0.1);
}

.range-button.active {
    color: #eff8ff;
    background: rgba(37, 99, 235, 0.56);
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.2);
}

.chart-wrap {
    position: relative;
    height: 280px;
}

#energyChart {
    display: block;
    width: 100%;
    height: 100%;
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    color: var(--muted);
    text-align: center;
    font-size: 13px;
}

.chart-empty[hidden],
.chart-tooltip[hidden] { display: none; }

.chart-tooltip {
    position: absolute;
    z-index: 3;
    min-width: 170px;
    padding: 10px 12px;
    pointer-events: none;
    border: 1px solid rgba(96, 165, 250, 0.28);
    border-radius: 10px;
    background: rgba(5, 12, 25, 0.96);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
    color: #dbeafe;
    font-size: 11px;
    line-height: 1.65;
}

.tooltip-time {
    color: var(--text);
    font-weight: 750;
}

.energy-details {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 13px;
}

.detail-chip {
    padding: 7px 10px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 9px;
    background: rgba(3, 9, 21, 0.42);
    color: var(--muted);
    font-size: 11px;
}

.detail-chip strong {
    margin-left: 4px;
    color: #dce7f4;
    font-weight: 700;
}

.energy-error {
    margin-top: 12px;
    color: #fda4af;
    font-size: 12px;
}
.energy-error:empty { display: none; }

.servers-section { margin-top: 8px; }

.server-count {
    display: inline-flex;
    min-width: 29px;
    height: 25px;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: #93c5fd;
    font-size: 11px;
    vertical-align: 2px;
}

.message {
    margin-bottom: 17px;
    padding: 15px 17px;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: rgba(15, 27, 46, 0.82);
    color: #cbd5e1;
    backdrop-filter: blur(12px);
    font-size: 13px;
}
.message.error {
    border-color: rgba(251, 113, 133, 0.35);
    color: #fda4af;
}
.message[hidden] { display: none; }

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

.server-card {
    min-width: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(145deg,
        rgba(18, 31, 52, 0.88), rgba(8, 15, 29, 0.9));
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.27);
    backdrop-filter: blur(15px);
    transition: transform 150ms ease, border-color 150ms ease;
}

.server-card:hover {
    transform: translateY(-2px);
    border-color: rgba(96, 165, 250, 0.24);
}

.server-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.server-card h3 {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 18px;
    letter-spacing: -0.02em;
}

.node {
    margin: 6px 0 0;
    overflow-wrap: anywhere;
    color: var(--muted);
    font-size: 12px;
}

.server-state {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.server-state::before {
    width: 6px;
    height: 6px;
    content: "";
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 10px currentColor;
}

.state-running { color: var(--green); }
.state-offline, .state-unavailable { color: var(--red); }
.state-starting, .state-stopping, .state-other { color: var(--amber); }
.state-suspended { color: var(--orange); }

.stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 20px 0;
}

.stat {
    min-width: 0;
    padding: 11px 9px;
    border: 1px solid rgba(148, 163, 184, 0.08);
    border-radius: 10px;
    background: rgba(2, 7, 18, 0.48);
}

.value {
    margin-top: 6px;
    overflow-wrap: anywhere;
    color: #ecf4ff;
    font-size: 14px;
    font-weight: 720;
}

.buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

.power-button {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    font-size: 12px;
    font-weight: 750;
    transition: filter 140ms ease, transform 140ms ease, opacity 140ms ease;
}

.power-button:not(:disabled):hover {
    filter: brightness(1.12);
    transform: translateY(-1px);
}

.start-button {
    border-color: rgba(74, 222, 128, 0.26);
    background: linear-gradient(145deg, #15803d, #16a34a);
}
.stop-button {
    border-color: rgba(251, 113, 133, 0.26);
    background: linear-gradient(145deg, #be123c, #e11d48);
}

.power-button:disabled {
    border-color: rgba(148, 163, 184, 0.08);
    background: rgba(71, 85, 105, 0.3);
    color: #64748b;
    cursor: not-allowed;
    opacity: 0.68;
}

.card-error {
    min-height: 18px;
    margin-top: 11px;
    color: #fda4af;
    font-size: 11px;
}

@media (max-width: 1180px) {
    .energy-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    main { padding: 25px 16px 45px; }
    .dashboard-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .service-strip { justify-content: flex-start; }
    .energy-panel {
        padding: 18px;
        border-radius: 18px;
    }
    .payment-panel { grid-template-columns: 1fr; padding: 18px; border-radius: 18px; }
    .energy-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .chart-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .range-switcher { width: 100%; }
    .range-button {
        flex: 1;
        min-width: 0;
        padding-inline: 5px;
    }
    .chart-wrap { height: 240px; }
}

@media (max-width: 460px) {
    .brand { align-items: flex-start; }
    .brand-mark {
        width: 44px;
        height: 44px;
        border-radius: 13px;
        font-size: 21px;
    }
    .energy-summary, .server-grid { grid-template-columns: 1fr; }
    .energy-metric { min-height: 104px; }
    .chart-card { padding-inline: 10px; }
    .server-card { padding: 17px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; }
}
