:root {
  color-scheme: dark;
  --bg: #080c14;
  --panel: rgba(18, 27, 43, .88);
  --panel-strong: #141f32;
  --line: rgba(139, 164, 200, .15);
  --text: #f1f5ff;
  --muted: #8f9db4;
  --blue: #5aa2ff;
  --green: #35d38a;
  --orange: #ffb84d;
  --pink: #f173b8;
  --purple: #a98aff;
  --red: #ff6474;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -5%, rgba(46, 109, 220, .18), transparent 32rem),
    linear-gradient(180deg, #090e18 0%, #070b12 100%);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}

button { font: inherit; }
.ambient { position: fixed; border-radius: 50%; filter: blur(90px); opacity: .11; pointer-events: none; }
.ambient-one { width: 24rem; height: 24rem; right: -12rem; top: 22rem; background: var(--purple); }
.ambient-two { width: 18rem; height: 18rem; left: -10rem; top: 65rem; background: var(--green); }
.shell { width: min(1180px, 100%); margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom)); }
.hidden { display: none !important; }

.topbar { display: flex; justify-content: space-between; align-items: center; margin: 2px 0 22px; }
.eyebrow, .section-kicker { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.live-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(53, 211, 138, .1); }
h1 { margin: 6px 0 2px; font-size: clamp(29px, 6vw, 44px); line-height: 1; letter-spacing: -.045em; }
.topbar p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.icon-button { display: grid; place-items: center; width: 46px; height: 46px; border: 1px solid var(--line); border-radius: 15px; color: var(--text); background: var(--panel); cursor: pointer; }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.loading svg { animation: spin .8s linear infinite; }

.hero-grid, .money-grid { display: grid; gap: 11px; grid-template-columns: repeat(4, 1fr); }
.money-grid { margin-top: 11px; }
.metric { position: relative; overflow: hidden; padding: 17px; border: 1px solid var(--line); border-radius: 19px; background: linear-gradient(145deg, rgba(22, 33, 53, .98), rgba(15, 24, 39, .94)); box-shadow: 0 16px 42px rgba(0, 0, 0, .16); }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--blue); }
.metric-label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.metric strong { display: block; overflow: hidden; font-size: clamp(19px, 3vw, 27px); line-height: 1.1; letter-spacing: -.035em; text-overflow: ellipsis; white-space: nowrap; }
.metric small { display: block; margin-top: 8px; color: var(--muted); font-size: 11px; }
.online-card::before, .profit::before { background: var(--green); }
.btc-card::before, .target::before { background: var(--purple); }
.electricity::before { background: var(--orange); }
.gross::before { background: var(--blue); }
.target::before { background: var(--pink); }

.section { margin-top: 30px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin: 0 2px 13px; }
.section-head h2 { margin: 3px 0 0; font-size: 24px; letter-spacing: -.035em; }
.period-switch { display: flex; padding: 4px; border: 1px solid var(--line); border-radius: 13px; background: rgba(13, 20, 33, .85); }
.period-switch button { padding: 8px 10px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 700; cursor: pointer; }
.period-switch button.active { color: #fff; background: #2869d8; box-shadow: 0 5px 16px rgba(40, 105, 216, .32); }

.chart-card { min-width: 0; padding: 14px 13px 10px; border: 1px solid var(--line); border-radius: 20px; background: rgba(16, 25, 41, .9); box-shadow: 0 18px 45px rgba(0, 0, 0, .17); }
.chart-card.large { padding-top: 16px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 11px; }
.canvas-wrap { position: relative; height: 290px; }
.canvas-wrap.compact { height: 200px; }
canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; }
.legend { display: flex; flex-wrap: wrap; gap: 13px; padding: 0 5px 10px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 3px; border-radius: 4px; }
.legend .blue { background: var(--blue); }
.legend .orange { background: var(--orange); }
.legend .green { background: var(--green); }
.chart-title { display: flex; justify-content: space-between; gap: 12px; padding: 2px 5px 10px; font-size: 13px; font-weight: 750; }
.chart-title span { color: var(--muted); font-size: 11px; font-weight: 600; }

.miners-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 11px; }
.miner { padding: 17px; border: 1px solid var(--line); border-radius: 19px; background: var(--panel); }
.miner-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.miner-name { margin: 0; font-size: 16px; letter-spacing: -.02em; }
.miner-type { margin-top: 4px; color: var(--muted); font-size: 11px; }
.state { flex: 0 0 auto; padding: 6px 9px; border-radius: 999px; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.state.online { color: #51e6a0; background: rgba(53, 211, 138, .12); }
.state.sleeping { color: #c1aaff; background: rgba(169, 138, 255, .13); }
.state.offline { color: #ff8290; background: rgba(255, 100, 116, .12); }
.miner-main { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 16px; }
.miner-value span { display: block; color: var(--muted); font-size: 10px; }
.miner-value strong { display: block; margin-top: 4px; font-size: 15px; }
.miner-foot { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.miner-profit { color: var(--green) !important; }
.miner-loss { color: var(--red) !important; }
.count-pill { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 11px; }

.loader { display: flex; min-height: 52vh; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.loader strong { margin-top: 16px; color: var(--text); }
.loader span { margin-top: 6px; font-size: 12px; }
.loader-ring { width: 38px; height: 38px; border: 3px solid rgba(90, 162, 255, .15); border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
.error { margin: 30px 0; padding: 18px; border: 1px solid rgba(255, 100, 116, .25); border-radius: 16px; color: #ff9ba6; background: rgba(255, 100, 116, .08); line-height: 1.5; }
footer { display: flex; justify-content: space-between; gap: 12px; margin: 27px 3px 0; color: #67748a; font-size: 10px; }

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

@media (max-width: 760px) {
  .shell { padding-left: 12px; padding-right: 12px; }
  .hero-grid, .money-grid { grid-template-columns: 1fr 1fr; }
  .metric { padding: 15px 14px; border-radius: 17px; }
  .metric strong { font-size: 20px; }
  .chart-grid, .miners-grid { grid-template-columns: 1fr; }
  .canvas-wrap { height: 250px; }
  .canvas-wrap.compact { height: 185px; }
  .chart-head { align-items: center; }
  .period-switch button { padding: 7px 8px; }
  footer { flex-direction: column; }
}

@media (max-width: 390px) {
  .metric strong { font-size: 18px; }
  .metric-label { font-size: 11px; }
  .period-switch button { font-size: 11px; padding: 7px; }
}
