:root {
  --bg: #100817;
  --bg-2: #1a0d28;
  --panel: rgba(39, 19, 57, 0.92);
  --panel-2: rgba(24, 11, 36, 0.92);
  --border: #7b3fb3;
  --border-soft: rgba(214, 168, 255, 0.22);
  --text: #f5ecff;
  --muted: #c9afd9;
  --gold: #f0c96a;
  --purple: #9d57ff;
  --purple-2: #6e2ed1;
  --green: #65d897;
  --red: #ff6b86;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(123, 63, 179, 0.35), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(240, 201, 106, 0.12), transparent 28rem),
    linear-gradient(135deg, var(--bg), #07040c 72%);
  color: var(--text);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
}

.container {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 34px 20px 56px;
}

.container.narrow {
  max-width: 760px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  margin-bottom: 30px;
}

.top-nav a,
.back-link,
.section-heading a {
  color: #e7d0ff;
  text-decoration: none;
  font-weight: 700;
}

.top-nav a {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(16, 8, 23, 0.58);
}

.top-nav a:hover,
.back-link:hover,
.section-heading a:hover {
  color: var(--gold);
}

.hero {
  margin-bottom: 26px;
  padding: 30px;
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(36, 17, 54, 0.9), rgba(15, 7, 22, 0.78));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

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

h1 {
  color: #dfbdff;
  font-size: clamp(2rem, 6vw, 4rem);
  margin-bottom: 10px;
}

h2 {
  color: #ead9ff;
}

h3 {
  margin-bottom: 4px;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

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

.section-heading h2 {
  margin-bottom: 0;
}

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
}

.resource-card {
  display: grid;
  gap: 14px;
  background: linear-gradient(180deg, rgba(47, 22, 70, 0.95), rgba(27, 12, 41, 0.95));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
}

.resource-title {
  display: flex;
  align-items: center;
  gap: 13px;
}

.resource-title p,
.muted {
  color: var(--muted);
  margin-bottom: 0;
}

.resource-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(240, 201, 106, 0.12);
  font-size: 1.6rem;
}

.price {
  color: var(--gold);
  font-size: 1.2rem;
  font-weight: 900;
}

.price.large {
  font-size: 1.75rem;
  margin-bottom: 18px;
}

.actions {
  display: flex;
  gap: 10px;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  color: white;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(110, 46, 209, 0.28);
}

.button.secondary {
  background: linear-gradient(135deg, #533067, #311841);
}

.button:hover,
button:hover {
  transform: translateY(-1px);
}

form {
  display: grid;
  gap: 12px;
  max-width: 480px;
}

label {
  color: #ead9ff;
  font-weight: 800;
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  background: rgba(8, 4, 12, 0.62);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(157, 87, 255, 0.35);
}

.warning,
.alert {
  border-radius: 14px;
  padding: 13px 15px;
  margin-bottom: 18px;
}

.warning {
  background: rgba(240, 201, 106, 0.12);
  border: 1px solid rgba(240, 201, 106, 0.35);
  color: #ffe6a3;
}

.alert-error {
  background: rgba(255, 107, 134, 0.12);
  border: 1px solid rgba(255, 107, 134, 0.42);
  color: #ffc7d1;
}

.alert-success {
  background: rgba(101, 216, 151, 0.12);
  border: 1px solid rgba(101, 216, 151, 0.42);
  color: #cbffe0;
}

.status-pill,
.side {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.status-pill.enabled,
.side.buy {
  background: rgba(101, 216, 151, 0.14);
  color: var(--green);
}

.status-pill.disabled,
.side.sell {
  background: rgba(255, 107, 134, 0.14);
  color: var(--red);
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

th {
  color: #e7d0ff;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.account-panel h2 {
  margin-bottom: 8px;
}

.wallet {
  overflow-wrap: anywhere;
  color: var(--muted);
}

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

.inventory-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}

.back-link {
  display: inline-block;
  margin-top: 8px;
}

@media (max-width: 640px) {
  .top-nav {
    justify-content: flex-start;
  }

  .hero,
  .panel {
    padding: 20px;
  }

  .section-heading,
  .actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .button,
  button {
    width: 100%;
  }
}

.nav-links,
.auth-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.top-nav {
  align-items: center;
  justify-content: space-between;
}

.auth-nav {
  justify-content: flex-end;
}

.login-link {
  background: linear-gradient(135deg, #5865f2, #7b3fb3) !important;
  color: white !important;
}

.user-chip {
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(16, 8, 23, 0.58);
  color: var(--muted);
}

.user-chip strong {
  color: var(--text);
}

.logout-form {
  display: inline;
  max-width: none;
}

.link-button {
  min-height: 0;
  padding: 9px 14px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(16, 8, 23, 0.58);
  box-shadow: none;
  color: #e7d0ff;
}

.link-button:hover {
  color: var(--gold);
}

.hero-login {
  margin-top: 10px;
}

.auth-context {
  margin-bottom: 18px;
}

.wallet-inline {
  overflow-wrap: anywhere;
  color: #e7d0ff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.inventory-row strong {
  overflow-wrap: anywhere;
  text-align: right;
}

@media (max-width: 640px) {
  .nav-links,
  .auth-nav {
    width: 100%;
    justify-content: flex-start;
  }
}

/* RoA market intelligence polish */
:root {
  --void: #05030d;
  --void-2: #0b0615;
  --royal: #a866ff;
  --royal-soft: rgba(168, 102, 255, 0.28);
  --gold-soft: rgba(240, 201, 106, 0.18);
}

body {
  background:
    radial-gradient(circle at 16% 8%, rgba(117, 55, 190, 0.34), transparent 28rem),
    radial-gradient(circle at 80% 18%, rgba(240, 201, 106, 0.09), transparent 30rem),
    linear-gradient(145deg, var(--void), var(--void-2) 58%, #020106);
}

.hero-market {
  border-color: rgba(240, 201, 106, 0.22);
  background:
    linear-gradient(135deg, rgba(11, 6, 21, 0.95), rgba(31, 13, 52, 0.84)),
    radial-gradient(circle at 80% 20%, rgba(168, 102, 255, 0.22), transparent 22rem);
}

.hero-market h1,
.panel h2 {
  color: var(--gold);
  text-shadow: 0 0 24px rgba(240, 201, 106, 0.18);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card,
.portfolio-card {
  border: 1px solid rgba(240, 201, 106, 0.18);
  border-radius: 18px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(19, 9, 32, 0.94), rgba(7, 4, 14, 0.94));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 40px rgba(0, 0, 0, 0.24);
}

.stat-card span,
.portfolio-card span,
.price-label,
.trade-price-card span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-card strong,
.portfolio-card strong {
  display: block;
  margin-top: 7px;
  color: #ffe6a3;
  font-size: 1.15rem;
}

.stat-card small {
  color: var(--muted);
}

.enchanted-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.enchanted-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(168, 102, 255, 0.34);
  background:
    linear-gradient(180deg, rgba(26, 12, 45, 0.96), rgba(7, 4, 14, 0.96)),
    radial-gradient(circle at top right, rgba(168, 102, 255, 0.22), transparent 14rem);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.enchanted-card:hover {
  border-color: rgba(240, 201, 106, 0.42);
  box-shadow: 0 0 0 1px rgba(240, 201, 106, 0.09), 0 24px 60px rgba(94, 42, 160, 0.28);
  transform: translateY(-4px);
}

.card-glow {
  position: absolute;
  inset: -1px;
  pointer-events: none;
  background: linear-gradient(135deg, transparent, rgba(168, 102, 255, 0.08), transparent);
}

.price-row,
.market-intel,
.trade-intel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.change-badge,
.activity-pill,
.trend-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 900;
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.04);
}

.change-badge.positive,
.trend-tag.up,
.trend-tag.hot,
.activity-pill.demand {
  color: var(--green);
  border-color: rgba(101, 216, 151, 0.34);
  background: rgba(101, 216, 151, 0.1);
}

.change-badge.negative,
.trend-tag.down,
.activity-pill.supply {
  color: var(--red);
  border-color: rgba(255, 107, 134, 0.34);
  background: rgba(255, 107, 134, 0.1);
}

.change-badge.neutral,
.trend-tag.stable,
.activity-pill.balanced {
  color: var(--muted);
}

.gold-outline {
  background: transparent !important;
  border: 1px solid rgba(240, 201, 106, 0.58) !important;
  color: #ffe6a3 !important;
  box-shadow: inset 0 0 18px rgba(240, 201, 106, 0.08), 0 10px 26px rgba(0, 0, 0, 0.18) !important;
}

.gold-outline:hover {
  background: rgba(240, 201, 106, 0.12) !important;
}

.two-column-market {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 22px;
}

.activity-feed,
.mini-ledger {
  display: grid;
  gap: 12px;
}

.activity-item,
.mini-ledger-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-soft);
}

.activity-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: rgba(168, 102, 255, 0.14);
  box-shadow: 0 0 20px rgba(168, 102, 255, 0.12);
}

.activity-item div {
  display: grid;
  gap: 3px;
}

.activity-item span:not(.activity-icon),
.mini-ledger-row span:not(.side) {
  color: var(--muted);
}

.mini-ledger-row {
  justify-content: space-between;
}

.empty-state {
  border: 1px dashed rgba(240, 201, 106, 0.24);
  border-radius: 16px;
  padding: 18px;
  color: var(--muted);
  background: rgba(240, 201, 106, 0.06);
}

.trade-price-card {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid rgba(168, 102, 255, 0.28);
  border-radius: 18px;
  background: rgba(7, 4, 14, 0.46);
}

.trade-price-card strong {
  color: var(--gold);
  font-size: 1.6rem;
}

.filter-form {
  display: grid;
  grid-template-columns: auto minmax(120px, 180px) auto minmax(180px, 240px) auto auto;
  align-items: end;
  gap: 12px;
  max-width: none;
  margin-bottom: 20px;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 18px 0 24px;
}

.portfolio-card.total {
  border-color: rgba(240, 201, 106, 0.34);
  box-shadow: 0 0 34px rgba(240, 201, 106, 0.08);
}

.inventory-row small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 3px;
}

@media (max-width: 860px) {
  .two-column-market,
  .filter-form {
    grid-template-columns: 1fr;
  }
}
