:root {
    --bg: #07111f;
    --panel: rgba(8, 17, 32, 0.74);
    --panel-strong: rgba(12, 24, 44, 0.88);
    --line: rgba(255,255,255,0.09);
    --line-strong: rgba(125, 220, 255, 0.24);
    --text: #ecf4ff;
    --muted: rgba(236,244,255,0.64);
    --soft: rgba(236,244,255,0.42);
    --accent: #55d7ff;
    --accent-2: #7c5cff;
    --green: #42ff9d;
    --red: #ff6464;
    --orange: #ffbd66;
    --shadow: 0 18px 60px rgba(0,0,0,0.36);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button, input { font: inherit; }

.background {
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 10% 0%, rgba(85, 215, 255, 0.20), transparent 30%),
        radial-gradient(circle at 90% 8%, rgba(124, 92, 255, 0.20), transparent 34%),
        radial-gradient(circle at 70% 100%, rgba(66, 255, 157, 0.10), transparent 28%),
        linear-gradient(160deg, #08111f, #050b14 72%);
    pointer-events: none;
}

.background::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.7), transparent 86%);
}

.glass-card {
    border: 1px solid var(--line);
    background: var(--panel);
    backdrop-filter: blur(22px);
    border-radius: 26px;
    box-shadow: var(--shadow);
}

.admin-shell {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    min-height: 100vh;
    padding: 20px;
}

.sidebar {
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    font-weight: 900;
    font-size: 22px;
    color: #06111d;
    background: linear-gradient(135deg, var(--accent), var(--green));
    box-shadow: 0 10px 32px rgba(85, 215, 255, 0.26);
}

.brand strong { display: block; font-size: 16px; letter-spacing: 0.2px; }
.brand span { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

.nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 6px;
}

.nav-item {
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    text-align: left;
    padding: 12px 14px;
    border-radius: 16px;
    cursor: pointer;
    transition: 0.18s ease;
}

.nav-item:hover {
    color: var(--text);
    background: rgba(255,255,255,0.05);
}

.nav-item.active {
    color: var(--text);
    background: linear-gradient(135deg, rgba(85,215,255,0.18), rgba(124,92,255,0.15));
    border-color: var(--line-strong);
}

.workspace {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.topbar {
    min-height: 100px;
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.badge {
    display: inline-flex;
    padding: 6px 11px;
    border-radius: 999px;
    background: rgba(85, 215, 255, 0.16);
    color: #8fe7ff;
    border: 1px solid rgba(85,215,255,0.18);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.2px;
    margin-bottom: 8px;
}

.topbar h1 {
    margin: 0;
    font-size: clamp(26px, 4vw, 42px);
    letter-spacing: -1px;
}

.topbar-widgets {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.balance-pill {
    min-width: 148px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,0.055);
    border-radius: 18px;
    padding: 10px 12px;
}

.balance-pill span, .balance-pill small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.balance-pill strong {
    display: block;
    margin-top: 4px;
    color: var(--green);
    font-size: 17px;
    line-height: 1.2;
    white-space: nowrap;
}

.ghost-button, .primary-button {
    border: 1px solid var(--line);
    color: var(--text);
    padding: 11px 14px;
    border-radius: 15px;
    cursor: pointer;
    transition: 0.18s ease;
}

.ghost-button {
    background: rgba(255,255,255,0.055);
}

.ghost-button:hover, .primary-button:hover { transform: translateY(-1px); border-color: var(--line-strong); }

.ghost-button.danger { color: #ffb0b0; }
.ghost-button.full { width: 100%; margin-top: auto; }

.primary-button {
    background: linear-gradient(135deg, rgba(85,215,255,0.88), rgba(124,92,255,0.88));
    color: white;
    font-weight: 800;
}

.primary-button:disabled { opacity: 0.55; cursor: wait; transform: none; }

.status-dot {
    width: 16px;
    height: 16px;
    border-radius: 999px;
    background: var(--red);
    box-shadow: 0 0 20px rgba(255,100,100,0.6);
    flex: 0 0 auto;
}

.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 24px rgba(66,255,157,0.68);
}

.page { display: none; animation: pageIn 0.2s ease both; }
.page.active { display: block; }

@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tiles {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 14px;
}

.tile {
    padding: 18px;
    min-height: 112px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.tile span {
    color: var(--muted);
    font-size: 13px;
}

.tile strong {
    font-size: 34px;
    letter-spacing: -1px;
}

.live-tile strong { color: var(--green); }

.grid {
    margin-top: 20px;
    display: grid;
    gap: 20px;
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.panel {
    padding: 20px;
}

.page-panel { min-height: 520px; }

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h2 {
    margin: 0;
    font-size: 20px;
    letter-spacing: -0.2px;
}

.panel-header p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.panel-header > span {
    color: var(--accent);
    font-size: 12px;
    border: 1px solid var(--line);
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(255,255,255,0.05);
    white-space: nowrap;
}

.runtime-list {
    display: flex;
    flex-direction: column;
    gap: 11px;
}

.runtime-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border-radius: 15px;
    background: rgba(255,255,255,0.045);
}

.runtime-list span { color: var(--muted); }
.runtime-list strong { color: var(--text); }

.console {
    min-height: 340px;
    max-height: 340px;
    overflow: auto;
    border-radius: 18px;
    padding: 14px;
    background: rgba(0,0,0,0.24);
    border: 1px solid rgba(255,255,255,0.06);
    font-family: Consolas, "JetBrains Mono", monospace;
    font-size: 12px;
}

.console-entry {
    margin-bottom: 9px;
    color: #8fdfff;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.table-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.admin-table {
    max-height: calc(100vh - 230px);
    overflow: auto;
    padding-right: 4px;
}

.table-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 16px;
    padding: 14px;
    border-radius: 18px;
    background: rgba(255,255,255,0.045);
    border: 1px solid rgba(255,255,255,0.055);
}

.table-item:hover {
    border-color: var(--line-strong);
    background: rgba(255,255,255,0.065);
}

.table-main { min-width: 0; }
.table-item-title { font-weight: 800; overflow-wrap: anywhere; }
.table-item-subtitle { font-size: 12px; color: var(--muted); margin-top: 5px; overflow-wrap: anywhere; }
.table-item-meta { color: var(--accent); font-size: 12px; text-align: right; max-width: 190px; overflow-wrap: anywhere; }
.table-item.muted { opacity: 0.75; }

.chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.chips span {
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(85, 215, 255, 0.10);
    color: #9feaff;
    border: 1px solid rgba(85, 215, 255, 0.14);
    font-size: 11px;
}

.search-input, .identity-bind-form input {
    width: 100%;
    border: 1px solid var(--line);
    outline: none;
    border-radius: 15px;
    background: rgba(0,0,0,0.20);
    color: var(--text);
    padding: 12px 13px;
}

.search-input:focus, .identity-bind-form input:focus {
    border-color: var(--line-strong);
    box-shadow: 0 0 0 3px rgba(85,215,255,0.08);
}

.identity-bind-form {
    display: grid;
    gap: 12px;
}

.identity-bind-form label span {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 12px;
}

.bind-result {
    margin-top: 14px;
    border-radius: 16px;
    padding: 12px;
    background: rgba(0,0,0,0.18);
    color: var(--muted);
    border: 1px solid rgba(255,255,255,0.055);
    overflow-wrap: anywhere;
}

.inline-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 14px;
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); border-radius: 999px; }
::-webkit-scrollbar-thumb { background: rgba(85,215,255,0.28); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(85,215,255,0.42); }

@media (max-width: 1320px) {
    .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
    .admin-shell { grid-template-columns: 1fr; padding: 12px; }
    .sidebar { position: relative; top: auto; height: auto; }
    .nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { align-items: flex-start; flex-direction: column; }
    .topbar-widgets { width: 100%; justify-content: flex-start; }
    .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .inline-form { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .tiles { grid-template-columns: 1fr; }
    .nav { grid-template-columns: 1fr; }
    .table-item { grid-template-columns: 1fr; }
    .table-item-meta { text-align: left; max-width: none; }
    .balance-pill { min-width: calc(50% - 5px); }
}
