:root {
  color-scheme: dark;
  --bg: #070b0b;
  --panel: rgba(13, 18, 18, .88);
  --panel-2: rgba(20, 30, 28, .86);
  --ink: #f5efe0;
  --muted: #a99f88;
  --line: rgba(198, 168, 96, .18);
  --line-strong: rgba(229, 190, 94, .38);
  --accent: #17a88b;
  --accent-ink: #a6f0d8;
  --accent-soft: rgba(23, 168, 139, .14);
  --good: #86e19d;
  --good-soft: rgba(134, 225, 157, .12);
  --danger: #ff6b5f;
  --danger-soft: rgba(255, 107, 95, .13);
  --warn: #e8b657;
  --warn-soft: rgba(232, 182, 87, .14);
  --purple: #c8a86a;
  --purple-soft: rgba(200, 168, 106, .12);
  --gold: #e8c779;
  --cinnabar: #b94a36;
  --shadow: 0 22px 58px rgba(0, 0, 0, .38);
  --xianxia-hero: url("/static/rebrand/smarttrade_xianxia_hero.png");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(126deg, rgba(23, 168, 139, .14), transparent 28% 72%, rgba(185, 74, 54, .11)),
    linear-gradient(22deg, transparent 0 46%, rgba(232, 199, 121, .08) 47%, transparent 49% 100%),
    linear-gradient(180deg, #07100f 0%, var(--bg) 54%, #050606 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 42%, rgba(232, 199, 121, .12) 43%, transparent 46% 100%),
    linear-gradient(68deg, transparent 0 58%, rgba(23, 168, 139, .10) 59%, transparent 62% 100%);
  background-size: 320px 320px, 420px 420px;
  opacity: .45;
  mix-blend-mode: screen;
  animation: talismanFlow 18s linear infinite;
  z-index: -1;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.boot-screen,
.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
}

.boot-screen {
  grid-template-columns: auto auto;
  gap: 16px;
}

.boot-screen h1,
.auth-card h1 {
  margin: 0 0 4px;
  font-size: 30px;
  line-height: 1.05;
}

.boot-screen p,
.auth-card p {
  margin: 0;
  color: var(--muted);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(232, 199, 121, .55);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(232, 199, 121, .20), rgba(23, 168, 139, .10)),
    #07100f;
  color: var(--gold);
  font-weight: 800;
  box-shadow: 0 0 18px rgba(232, 199, 121, .13), inset 0 0 18px rgba(232, 199, 121, .09);
}

.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--xianxia-hero) center / cover no-repeat;
  opacity: .18;
  filter: saturate(.75);
  z-index: -1;
}

.auth-card form {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 12px;
  background: rgba(2, 8, 8, .72);
  color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(5, 11, 10, .94), rgba(8, 15, 14, .84)),
    var(--xianxia-hero) center / cover no-repeat;
  backdrop-filter: blur(18px);
  padding: 18px;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.side-brand small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.account-tab {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.account-tab:hover,
.account-tab.active {
  border-color: var(--line-strong);
  background: var(--panel);
}

.account-tab.active {
  box-shadow: inset 3px 0 0 var(--gold), 0 12px 30px rgba(0, 0, 0, .18);
}

.account-tab strong {
  display: block;
  overflow-wrap: anywhere;
}

.account-tab span {
  color: var(--muted);
  font-size: 12px;
}

.content {
  min-width: 0;
  padding: 22px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.button,
.ghost-button,
.danger-button {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  padding: 0 12px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
}

.button {
  border-color: rgba(232, 199, 121, .58);
  background: linear-gradient(135deg, #e8c779, #17a88b);
  color: #06100e;
}

.danger-button {
  border-color: rgba(180, 35, 24, .24);
  background: var(--danger-soft);
  color: var(--danger);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.cult-hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(232, 199, 121, .28);
  border-radius: 8px;
  background: #06100e;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  isolation: isolate;
}

.cult-hero-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(3, 8, 7, .92) 0%, rgba(3, 8, 7, .72) 34%, rgba(3, 8, 7, .28) 72%),
    linear-gradient(180deg, rgba(3, 8, 7, .14), rgba(3, 8, 7, .68)),
    var(--xianxia-hero) center / cover no-repeat;
  transform: scale(1.02);
  animation: mountainBreath 12s ease-in-out infinite;
  z-index: -3;
}

.cult-hero::before,
.cult-hero::after {
  content: "";
  position: absolute;
  inset: -30%;
  pointer-events: none;
  z-index: -1;
}

.cult-hero::before {
  background:
    linear-gradient(108deg, transparent 0 45%, rgba(232, 199, 121, .34) 46%, transparent 47% 100%),
    linear-gradient(78deg, transparent 0 60%, rgba(23, 168, 139, .24) 61%, transparent 62% 100%);
  background-size: 520px 520px, 680px 680px;
  opacity: .34;
  animation: talismanFlow 14s linear infinite;
}

.cult-hero::after {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(245, 239, 224, .12), transparent 44%),
    linear-gradient(180deg, transparent 42%, rgba(245, 239, 224, .08) 50%, transparent 62%);
  transform: translateY(8%);
  animation: mistDrift 9s ease-in-out infinite;
  opacity: .75;
}

.cult-hero-copy {
  align-self: end;
  max-width: 690px;
  padding: 30px;
}

.cult-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.cult-hero h2 {
  margin: 0;
  color: var(--ink);
  font-size: 76px;
  line-height: .9;
  text-shadow: 0 0 30px rgba(232, 199, 121, .22);
}

.cult-hero p {
  max-width: 560px;
  margin: 14px 0 18px;
  color: #d9cfb6;
  font-size: 15px;
  line-height: 1.65;
}

.realm-progress {
  width: min(460px, 100%);
  height: 10px;
  overflow: hidden;
  border: 1px solid rgba(232, 199, 121, .28);
  border-radius: 999px;
  background: rgba(0, 0, 0, .36);
}

.realm-progress div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cinnabar), var(--gold), var(--accent));
  box-shadow: 0 0 18px rgba(232, 199, 121, .28);
  animation: qiPulse 2.8s ease-in-out infinite;
}

.cult-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.cult-stats span {
  border: 1px solid rgba(232, 199, 121, .18);
  border-radius: 6px;
  background: rgba(5, 10, 9, .58);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
}

.cult-stats b {
  color: var(--gold);
}

.cult-sigil {
  position: relative;
  width: 190px;
  min-height: 190px;
  align-self: center;
  margin-right: 28px;
  border: 1px solid rgba(232, 199, 121, .22);
  border-radius: 50%;
  background:
    conic-gradient(from 0deg, rgba(232, 199, 121, .08), rgba(23, 168, 139, .22), rgba(185, 74, 54, .11), rgba(232, 199, 121, .08));
  box-shadow: inset 0 0 38px rgba(232, 199, 121, .08), 0 0 54px rgba(23, 168, 139, .11);
  animation: sigilTurn 18s linear infinite;
}

.cult-sigil i {
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(232, 199, 121, .25);
  border-radius: 50%;
}

.cult-sigil i:nth-child(2) {
  inset: 48px;
  border-color: rgba(23, 168, 139, .32);
}

.cult-sigil i:nth-child(3) {
  inset: 78px;
  border-radius: 8px;
  transform: rotate(45deg);
  border-color: rgba(185, 74, 54, .35);
}

.cult-ledger {
  position: absolute;
  right: 24px;
  bottom: 22px;
  min-width: 230px;
  border: 1px solid rgba(232, 199, 121, .22);
  border-radius: 8px;
  background: rgba(5, 10, 9, .76);
  padding: 14px;
  backdrop-filter: blur(10px);
}

.cult-ledger span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.cult-ledger strong {
  display: block;
  margin: 4px 0;
  color: var(--gold);
  font-size: 28px;
  line-height: 1;
}

.metric-card,
.panel,
.table-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .24);
  backdrop-filter: blur(16px);
}

.metric-card {
  min-height: 112px;
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(232, 199, 121, .58), transparent);
  transform: translateX(-100%);
  animation: swordLight 5.4s ease-in-out infinite;
}

.metric-card label,
.panel-title small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 30px;
  line-height: 1;
}

.metric-card span {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr);
  gap: 14px;
  align-items: stretch;
}

.panel {
  padding: 16px;
  min-width: 0;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-title h2,
.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.panel-title p,
.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart-box {
  width: 100%;
  height: 292px;
}

.chart-box canvas {
  width: 100%;
  height: 100%;
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, .18);
}

.account-state {
  display: grid;
  gap: 12px;
}

.wallet-list {
  display: grid;
  gap: 10px;
}

.wallet-row,
.health-row,
.trade-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.wallet-row:last-child,
.health-row:last-child,
.trade-stat-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.wallet-row span,
.health-row span,
.trade-stat-row span {
  color: var(--muted);
  font-size: 13px;
}

.wallet-row strong,
.health-row strong,
.trade-stat-row strong {
  text-align: right;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  padding: 0 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.badge.good {
  border-color: rgba(22, 128, 60, .22);
  background: var(--good-soft);
  color: var(--good);
}

.badge.bad {
  border-color: rgba(180, 35, 24, .24);
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.warn {
  border-color: rgba(161, 98, 7, .24);
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.purple {
  border-color: rgba(105, 65, 198, .24);
  background: var(--purple-soft);
  color: var(--purple);
}

.good {
  color: var(--good);
}

.bad {
  color: var(--danger);
}

.flat,
.muted {
  color: var(--muted);
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 0 10px;
}

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

.ops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.ops-tile {
  min-height: 126px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(28, 25, 23, .04);
  padding: 14px;
}

.ops-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ops-tile strong {
  display: block;
  margin-top: 14px;
  font-size: 22px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.ops-tile p,
.ops-queue-row p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.ops-panel {
  margin-bottom: 12px;
}

.ops-queue {
  display: grid;
  gap: 10px;
}

.ops-queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.ops-queue-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.ops-row-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ops-row-title span:last-child {
  color: var(--ink);
  font-weight: 750;
}

.ops-secondary {
  margin-bottom: 12px;
}

.report-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  margin-bottom: 18px;
  overflow: hidden;
}

.report-detail summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--muted);
  font-weight: 800;
}

.report-detail pre {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  padding: 14px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.slots {
  display: grid;
  grid-template-columns: repeat(var(--slot-count, 3), minmax(18px, 1fr));
  gap: 6px;
  margin-top: 14px;
}

.slot {
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
}

.slot.used {
  border-color: var(--accent);
  background: linear-gradient(180deg, var(--gold), var(--accent));
  box-shadow: 0 0 16px rgba(23, 168, 139, .24);
}

.mix-bar {
  display: grid;
  grid-template-columns: var(--wins, 1fr) var(--losses, 1fr) var(--unknown, 1fr);
  height: 14px;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid var(--line);
  margin: 14px 0 10px;
}

.mix-bar div:nth-child(1) {
  background: var(--good);
}

.mix-bar div:nth-child(2) {
  background: var(--danger);
}

.mix-bar div:nth-child(3) {
  background: var(--line-strong);
}

.table-panel {
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

@keyframes talismanFlow {
  from { background-position: 0 0, 0 0; }
  to { background-position: 520px 520px, -680px 680px; }
}

@keyframes mountainBreath {
  0%, 100% { transform: scale(1.02) translateY(0); filter: saturate(.86) brightness(.92); }
  50% { transform: scale(1.055) translateY(-6px); filter: saturate(1.02) brightness(1.05); }
}

@keyframes mistDrift {
  0%, 100% { transform: translate3d(-2%, 8%, 0); opacity: .56; }
  50% { transform: translate3d(3%, 4%, 0); opacity: .82; }
}

@keyframes qiPulse {
  0%, 100% { filter: brightness(.9); }
  50% { filter: brightness(1.35); }
}

@keyframes sigilTurn {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes swordLight {
  0%, 42% { transform: translateX(-100%); opacity: 0; }
  50% { opacity: 1; }
  65%, 100% { transform: translateX(100%); opacity: 0; }
}

td {
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.empty {
  display: grid;
  min-height: 128px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.alert-list {
  display: grid;
  gap: 8px;
}

.alert-item {
  border: 1px solid rgba(180, 35, 24, .18);
  border-radius: 6px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
}

.footer-note {
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0 0;
}

.error-box {
  border: 1px solid rgba(180, 35, 24, .28);
  border-radius: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  padding: 14px;
  margin: 14px 0;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .summary-grid,
  .grid-3,
  .ops-grid,
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .cult-hero {
    grid-template-columns: 1fr;
  }

  .cult-sigil {
    display: none;
  }

  .cult-ledger {
    position: static;
    margin: 0 18px 18px;
  }
}

@media (max-width: 680px) {
  .content,
  .sidebar {
    padding: 14px;
  }

  .topbar,
  .section-title,
  .panel-title {
    display: grid;
  }

  .top-actions {
    justify-content: stretch;
  }

  .top-actions > * {
    width: 100%;
  }

  .summary-grid,
  .nav-stack {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 96px;
  }

  .cult-hero-copy {
    padding: 22px;
  }

  .cult-hero h2 {
    font-size: 46px;
  }

  .topbar h1 {
    font-size: 27px;
  }

  .metric-card strong {
    font-size: 26px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
