:root {
    --bg: #060812;
    --bg-2: #0b1020;
    --panel: rgba(12, 19, 34, 0.82);
    --panel-2: rgba(18, 30, 52, 0.72);
    --text: #e8f1ff;
    --muted: #8fa2bd;
    --line: rgba(148, 163, 184, 0.18);
    --blue: #38bdf8;
    --green: #22c55e;
    --red: #ef4444;
    --yellow: #f59e0b;
    --violet: #a855f7;
    --shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: Inter, "Segoe UI", system-ui, sans-serif;
    background:
        linear-gradient(115deg, rgba(56, 189, 248, 0.10), transparent 28%),
        linear-gradient(235deg, rgba(168, 85, 247, 0.10), transparent 30%),
        linear-gradient(180deg, var(--bg), var(--bg-2));
    overflow-x: hidden;
    animation: pageGradientDrift 18s ease-in-out infinite alternate;
}

@keyframes pageGradientDrift {
    from { background-position: 0 0, 0 0, 0 0; }
    to { background-position: 120px -80px, -100px 110px, 0 0; }
}

body.theme-hacker {
    --bg: #000704;
    --bg-2: #03150d;
    --panel: rgba(0, 20, 12, 0.84);
    --panel-2: rgba(0, 32, 18, 0.72);
    --text: #d6ffe6;
    --muted: #77b98d;
    --line: rgba(34, 197, 94, 0.28);
    --blue: #00ffcc;
    --green: #39ff14;
    --red: #ff3158;
    --yellow: #d7ff43;
    --violet: #00ffaa;
    background:
        linear-gradient(180deg, rgba(0, 255, 100, 0.08), transparent 26%),
        linear-gradient(110deg, #000000, #03150d 52%, #001b10);
}

body.theme-hacker::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.035) 0,
        rgba(255, 255, 255, 0.035) 1px,
        transparent 2px,
        transparent 5px
    );
    mix-blend-mode: overlay;
    animation: scanlineMove 6s linear infinite;
    z-index: 6;
}

@keyframes scanlineMove {
    from { transform: translateY(-12px); }
    to { transform: translateY(12px); }
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

#matrixCanvas,
#particleCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#matrixCanvas {
    opacity: 0;
    z-index: 0;
    transition: opacity 0.25s ease;
}

body.theme-hacker #matrixCanvas {
    opacity: 0.55;
}

#particleCanvas {
    opacity: 0.22;
    z-index: 0;
}

.grid-backdrop {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(56, 189, 248, 0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56, 189, 248, 0.08) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,0.95), transparent 78%);
    pointer-events: none;
    animation: gridDrift 18s linear infinite;
    z-index: 0;
}

body.theme-hacker .grid-backdrop {
    background-image:
        linear-gradient(rgba(57, 255, 20, 0.16) 1px, transparent 1px),
        linear-gradient(90deg, rgba(57, 255, 20, 0.14) 1px, transparent 1px);
}

@keyframes gridDrift {
    from { background-position: 0 0; }
    to { background-position: 84px 84px; }
}

#cursorGlow {
    position: fixed;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.16), transparent 65%);
    transform: translate(-50%, -50%);
    z-index: 1;
    opacity: 0.85;
    transition: opacity 0.2s ease;
}

body.theme-hacker #cursorGlow {
    background: radial-gradient(circle, rgba(57, 255, 20, 0.24), transparent 65%);
}

.page-loader {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background:
        radial-gradient(circle at 48% 44%, rgba(56, 189, 248, 0.18), transparent 30%),
        radial-gradient(circle at 55% 58%, rgba(34, 197, 94, 0.14), transparent 26%),
        rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(18px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 80;
    transition: opacity 0.22s ease, visibility 0.22s ease;
}

.page-loader.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.loader-miner {
    position: relative;
    width: min(380px, calc(100vw - 34px));
    min-height: 310px;
    display: grid;
    justify-items: center;
    gap: 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 30px 24px;
    background:
        linear-gradient(135deg, rgba(56, 189, 248, 0.13), transparent 42%),
        rgba(6, 12, 22, 0.92);
    box-shadow: 0 30px 110px rgba(0, 0, 0, 0.72), 0 0 34px rgba(34, 197, 94, 0.10);
}

.loader-miner::before {
    content: "";
    position: absolute;
    inset: 14px;
    border: 1px solid rgba(245, 158, 11, 0.18);
    border-radius: 10px;
    pointer-events: none;
    background:
        linear-gradient(90deg, transparent 0 18px, rgba(245, 158, 11, 0.14) 18px 19px, transparent 19px 38px),
        linear-gradient(0deg, transparent 0 18px, rgba(56, 189, 248, 0.12) 18px 19px, transparent 19px 38px);
    opacity: 0.35;
    animation: loaderGridMine 2.1s linear infinite;
}

@keyframes loaderGridMine {
    from { background-position: 0 0; }
    to { background-position: 76px 76px; }
}

.loader-cube {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 18px 0 6px;
    transform-style: preserve-3d;
    animation: loaderCubeSpin 1.55s linear infinite;
}

.loader-cube .side {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border: 1px solid rgba(245, 158, 11, 0.62);
    background:
        radial-gradient(circle at 50% 42%, rgba(245, 158, 11, 0.32), transparent 55%),
        rgba(15, 23, 42, 0.92);
    color: #ffe8b8;
    font-size: 0.72rem;
    font-weight: 950;
    letter-spacing: 0.12em;
    text-shadow: 0 0 12px rgba(245, 158, 11, 0.60);
    box-shadow: inset 0 0 24px rgba(245, 158, 11, 0.12), 0 0 18px rgba(245, 158, 11, 0.14);
}

.loader-cube .front { transform: translateZ(48px); }
.loader-cube .back { transform: rotateY(180deg) translateZ(48px); }
.loader-cube .right { transform: rotateY(90deg) translateZ(48px); }
.loader-cube .left { transform: rotateY(-90deg) translateZ(48px); }
.loader-cube .top { transform: rotateX(90deg) translateZ(48px); }
.loader-cube .bottom { transform: rotateX(-90deg) translateZ(48px); }

@keyframes loaderCubeSpin {
    from { transform: rotateX(-18deg) rotateY(0deg) rotateZ(0deg); }
    to { transform: rotateX(-18deg) rotateY(360deg) rotateZ(360deg); }
}

.loader-pickaxe {
    position: relative;
    width: 120px;
    height: 56px;
    z-index: 1;
}

.loader-pickaxe::before,
.loader-pickaxe::after {
    content: "";
    position: absolute;
    left: 52px;
    top: 5px;
    width: 9px;
    height: 58px;
    border-radius: 999px;
    background: linear-gradient(#f8fafc, #38bdf8);
    transform-origin: 50% 80%;
    animation: pickaxeStrike 0.72s ease-in-out infinite;
}

.loader-pickaxe::after {
    left: 24px;
    top: 12px;
    width: 72px;
    height: 9px;
    background: linear-gradient(90deg, transparent, #f59e0b 20% 80%, transparent);
    box-shadow: 0 0 22px rgba(245, 158, 11, 0.40);
}

@keyframes pickaxeStrike {
    0%, 100% { transform: rotate(-28deg); }
    50% { transform: rotate(25deg); }
}

.loader-sparks {
    position: absolute;
    left: 50%;
    top: 168px;
    width: 160px;
    height: 78px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 0;
}

.loader-sparks i {
    position: absolute;
    left: 50%;
    top: 38px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 0 18px rgba(245, 158, 11, 0.86);
    animation: mineSpark 0.78s ease-out infinite;
}

.loader-sparks i:nth-child(1) { --sx: -58px; --sy: -28px; animation-delay: 0ms; }
.loader-sparks i:nth-child(2) { --sx: -32px; --sy: -48px; animation-delay: 90ms; }
.loader-sparks i:nth-child(3) { --sx: 18px; --sy: -42px; animation-delay: 150ms; }
.loader-sparks i:nth-child(4) { --sx: 46px; --sy: -24px; animation-delay: 240ms; }
.loader-sparks i:nth-child(5) { --sx: -12px; --sy: 20px; animation-delay: 310ms; }
.loader-sparks i:nth-child(6) { --sx: 66px; --sy: 12px; animation-delay: 390ms; }

@keyframes mineSpark {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.65);
    }
    to {
        opacity: 0;
        transform: translate(calc(-50% + var(--sx)), calc(-50% + var(--sy))) scale(0.12);
    }
}

.loader-copy {
    display: grid;
    gap: 5px;
    text-align: center;
}

.loader-copy strong {
    font-size: 1.15rem;
}

.loader-copy span {
    color: var(--muted);
    font-size: 0.86rem;
}

.loader-progress {
    width: 100%;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.14);
}

.loader-progress span {
    display: block;
    width: 42%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--blue), var(--green), var(--yellow));
    animation: loaderProgress 1.05s ease-in-out infinite;
}

@keyframes loaderProgress {
    from { transform: translateX(-110%); }
    to { transform: translateX(245%); }
}

body.theme-hacker .page-loader {
    background:
        radial-gradient(circle at 50% 45%, rgba(57, 255, 20, 0.18), transparent 32%),
        rgba(0, 7, 4, 0.86);
}

body.theme-hacker .loader-miner {
    border-color: rgba(57, 255, 20, 0.36);
    box-shadow: 0 30px 110px rgba(0, 0, 0, 0.72), 0 0 44px rgba(57, 255, 20, 0.16);
}

.crt-frame {
    position: fixed;
    inset: 8px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 12px;
    pointer-events: none;
    z-index: 8;
    box-shadow:
        inset 0 0 52px rgba(0, 0, 0, 0.52),
        inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

body.theme-hacker .crt-frame {
    border-color: rgba(57, 255, 20, 0.28);
    box-shadow:
        inset 0 0 58px rgba(0, 0, 0, 0.70),
        inset 0 0 24px rgba(57, 255, 20, 0.10),
        0 0 26px rgba(57, 255, 20, 0.06);
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    padding: 18px;
    background: rgba(3, 8, 18, 0.82);
    border-right: 1px solid var(--line);
    backdrop-filter: blur(20px);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

body.theme-hacker .sidebar {
    box-shadow: 0 0 30px rgba(57, 255, 20, 0.08);
}

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

.brand-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    color: white;
    font-weight: 950;
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.45), rgba(34, 197, 94, 0.24));
    border: 1px solid var(--line);
    animation: glowPulse 2.2s ease-in-out infinite alternate;
}

@keyframes glowPulse {
    from { box-shadow: 0 0 8px rgba(56, 189, 248, 0.25); }
    to { box-shadow: 0 0 26px rgba(34, 197, 94, 0.38); }
}

.brand-title {
    font-weight: 950;
    letter-spacing: 0;
}

.brand-sub,
.muted,
.small {
    color: var(--muted);
}

.brand-sub,
.small {
    font-size: 0.78rem;
}

.nav {
    display: grid;
    gap: 5px;
}

.nav-link {
    position: relative;
    padding: 11px 12px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--muted);
    font-weight: 800;
    transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
    background: rgba(56, 189, 248, 0.08);
    border-color: var(--line);
    transform: translateX(3px);
}

body.theme-hacker .nav-link.active {
    color: var(--green);
    text-shadow: 0 0 14px rgba(57, 255, 20, 0.55);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: 10px;
}

.sync-pill,
.status-pill {
    border: 1px solid var(--line);
    background: rgba(12, 19, 34, 0.70);
    border-radius: 999px;
    color: var(--muted);
    padding: 9px 12px;
    font-size: 0.82rem;
}

.logout-link {
    padding: 10px 12px;
    border: 1px solid rgba(239, 68, 68, 0.32);
    color: #ffd8d8;
    border-radius: var(--radius);
    text-align: center;
    text-decoration: none;
    font-weight: 900;
    background: rgba(239, 68, 68, 0.10);
}

.app-shell {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    margin-left: 260px;
    padding: 22px;
}

.topbar {
    min-height: 78px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 0 20px;
    border-bottom: 1px solid var(--line);
}

.page-title-block {
    min-width: 0;
}

.eyebrow,
.panel-label,
.stat-label {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: 0.72rem;
    font-weight: 900;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(1.45rem, 2.4vw, 2.4rem);
    letter-spacing: 0;
}

.page-title-block p {
    margin-top: 4px;
    color: var(--muted);
}

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

.menu-button {
    display: none;
}

.icon-button,
.theme-toggle,
.action-button {
    border: 1px solid var(--line);
    background: rgba(12, 19, 34, 0.72);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 13px;
    cursor: pointer;
    font-weight: 900;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.action-button.danger {
    border-color: rgba(239, 68, 68, 0.35);
    background: rgba(239, 68, 68, 0.14);
}

.icon-button:hover,
.theme-toggle:hover,
.action-button:hover {
    transform: translateY(-2px);
    border-color: rgba(56, 189, 248, 0.55);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.toggle-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--muted);
    box-shadow: 0 0 0 rgba(57, 255, 20, 0);
}

body.theme-hacker .toggle-dot {
    background: var(--green);
    box-shadow: 0 0 14px rgba(57, 255, 20, 0.8);
}

.content {
    padding: 22px 0;
}

.glitch-title {
    position: relative;
    display: inline-block;
}

.glitch-title::before,
.glitch-title::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0;
}

.glitch-title.glitching::before {
    opacity: 0.72;
    color: var(--red);
    transform: translate(-2px, 1px);
    clip-path: inset(0 0 54% 0);
}

.glitch-title.glitching::after {
    opacity: 0.72;
    color: var(--blue);
    transform: translate(2px, -1px);
    clip-path: inset(50% 0 0 0);
}

.command-palette {
    position: fixed;
    inset: 0;
    display: none;
    place-items: start center;
    padding-top: 12vh;
    background: rgba(0, 0, 0, 0.56);
    backdrop-filter: blur(14px);
    z-index: 40;
}

.command-palette.open {
    display: grid;
}

.command-box {
    width: min(720px, calc(100vw - 32px));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(6, 12, 22, 0.96);
    box-shadow: 0 24px 90px rgba(0, 0, 0, 0.62), 0 0 36px rgba(56, 189, 248, 0.08);
    padding: 16px;
    animation: commandIn 0.18s ease both;
}

@keyframes commandIn {
    from { opacity: 0; transform: translateY(-18px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.command-box input {
    width: 100%;
    margin: 10px 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 14px;
    background: rgba(2, 6, 23, 0.7);
    color: var(--text);
    outline: none;
}

.command-results {
    display: grid;
    gap: 8px;
    max-height: 420px;
    overflow: auto;
}

.command-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: var(--radius);
    color: inherit;
    text-decoration: none;
    padding: 11px;
    background: rgba(255, 255, 255, 0.03);
    transition: transform 0.16s ease, border-color 0.16s ease;
}

.command-result:hover,
.command-result.active {
    transform: translateX(4px);
    border-color: rgba(56, 189, 248, 0.52);
}

.hologram,
.stat-card,
.miner-card,
.glass {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--panel);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.hologram::before,
.stat-card::before,
.miner-card::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(120deg, rgba(56, 189, 248, 0.11), transparent 32%, rgba(34, 197, 94, 0.08));
    opacity: 0.72;
}

body.theme-hacker .hologram::after,
body.theme-hacker .stat-card::after,
body.theme-hacker .miner-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 22px rgba(57, 255, 20, 0.18), 0 0 24px rgba(57, 255, 20, 0.10);
    animation: neonFlicker 2.6s linear infinite;
}

@keyframes neonFlicker {
    0%, 100% { opacity: 0.82; }
    8% { opacity: 0.35; }
    10% { opacity: 1; }
    48% { opacity: 0.65; }
    50% { opacity: 0.95; }
}

.hologram > *,
.stat-card > *,
.miner-card > * {
    position: relative;
    z-index: 1;
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 22px 0 0;
    color: var(--muted);
    font-size: 0.78rem;
}

.toast-stack {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: min(360px, calc(100vw - 44px));
    display: grid;
    gap: 10px;
    z-index: 30;
}

.toast {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(12, 19, 34, 0.94);
    padding: 12px;
    box-shadow: var(--shadow);
    animation: toastIn 0.28s ease both;
}

.toast.ok { border-color: rgba(34, 197, 94, 0.45); }
.toast.warn { border-color: rgba(245, 158, 11, 0.45); }
.toast.danger { border-color: rgba(239, 68, 68, 0.45); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.error-shell {
    width: min(560px, calc(100vw - 32px));
    margin: 16vh auto;
    padding: 26px;
    text-align: center;
}
