:root {
  --bg: #0b1220;
  --bg2: #121a2b;
  --card: #162033;
  --line: #24324a;
  --text: #e8eefc;
  --muted: #93a0b8;
  --accent: #3dd6c6;
  --accent2: #f0b429;
  --up: #3dd68c;
  --down: #ff6b6b;
  --danger: #ff8f8f;
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1b3358 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #143d3a 0%, transparent 45%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
.demo-banner {
  display: none !important;
  background: linear-gradient(90deg, #5b3b00, #8a5a00);
  color: #fff6d8;
  text-align: center;
  padding: .55rem 1rem;
  font-size: .92rem;
  font-weight: 600;
}
.top {
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px); position: sticky; top: 0; background: rgba(11,18,32,.85); z-index: 10;
}
/* brand styles moved below */
nav { display: flex; gap: 1rem; flex-wrap: wrap; }
nav a { color: var(--muted); }
nav a:hover { color: #fff; }
.userbox { display: flex; gap: .8rem; align-items: center; color: var(--muted); font-size: .92rem; }
.wrap { width: min(1100px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.hero {
  display: block; margin-bottom: 2rem;
}
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); margin: .2rem 0 .6rem; }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 36rem; }
.eyebrow { color: var(--accent); letter-spacing: .14em; font-size: .75rem; margin: 0; }
.cta { display: flex; gap: .75rem; margin-top: 1.2rem; flex-wrap: wrap; }
.hero-card, .panel {
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent), var(--card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem;
}
.hero-card article { border-top: 1px solid var(--line); padding-top: .8rem; margin-top: .8rem; }
.hero-card p, .muted { color: var(--muted); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; padding: .65rem 1.1rem; border: 1px solid var(--line); color: #fff;
}
.btn.primary { background: linear-gradient(135deg, #2bb7a9, #1f8f9a); border: none; color: #04151a; font-weight: 700; }
.btn.ghost { background: transparent; }
.section-head { display: flex; justify-content: space-between; align-items: end; margin: 1rem 0 .7rem; gap: 1rem; }
.section-head h2 { margin: 0; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .85rem 1rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { color: var(--muted); font-weight: 600; font-size: .85rem; }
table.data td small { display: block; color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.trade-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 1rem; }
.stack { display: grid; gap: .8rem; }
label { display: grid; gap: .35rem; color: var(--muted); font-size: .92rem; }
input, select, textarea, button {
  font: inherit; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); padding: .7rem .8rem;
}
button { cursor: pointer; }
.big-price { font-size: 2rem; font-weight: 800; margin-right: .5rem; }
.pos-box { display: grid; gap: .35rem; margin-top: 1rem; color: var(--muted); }
.auth { max-width: 420px; margin: 2rem auto; }
.error { color: var(--danger); }
.foot { text-align: center; color: var(--muted); padding: 2rem 1rem 3rem; font-size: .9rem; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .8rem; }
.inline { display: flex; gap: .4rem; align-items: center; }
.inline input { width: 110px; }
.pill { background: #24324a; color: var(--accent2); border-radius: 999px; padding: .2rem .7rem; font-size: .8rem; }
.notice-list { color: var(--muted); }
@media (max-width: 840px) {
  .hero, .trade-grid, .grid-form { grid-template-columns: 1fr; }
  .top { flex-wrap: wrap; }
}


.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 800; font-size: 1.2rem; color: #fff; letter-spacing: .02em; }
.brand-logo { width: 36px; height: 36px; object-fit: cover; border-radius: 10px; background: transparent; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
.brand-text { line-height: 1; }
.hero-brand-logo { width: 80px; height: 80px; object-fit: cover; border-radius: 18px; margin-bottom: .55rem; background: transparent; border: 1px solid rgba(255,255,255,.1); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.foot-logo { width: 18px; height: 18px; object-fit: contain; vertical-align: -3px; margin-right: .35rem; border-radius: 4px; }
.brand-preview { display: flex; gap: .9rem; align-items: center; padding: .6rem 0 0.2rem; }
.brand-preview-img { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); }
.brand-preview-fallback { width: 56px; height: 56px; border-radius: 12px; display:grid; place-items:center; font-weight:800; background: linear-gradient(135deg,#2bb7a9,#1f8f9a); color:#04151a; }
.brand-form .check { display:flex; align-items:center; gap:.5rem; color: var(--muted); }
.ok { color: var(--up); margin: 0 0 1rem; }


/* ---- Customer Support ---- */
.cs-fab {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 40;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  background: linear-gradient(135deg, #2bb7a9, #1f8f9a); color: #04151a;
  font-weight: 800; font-size: .92rem; cursor: pointer;
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
}
.cs-fab .cs-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: .7rem; display: none; align-items: center; justify-content: center; padding: 0 4px;
}
.cs-panel {
  position: fixed; right: 1.1rem; bottom: 5rem; z-index: 41;
  width: min(380px, calc(100vw - 1.5rem)); height: min(520px, calc(100vh - 7rem));
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,.45); display: none; flex-direction: column; overflow: hidden;
}
.cs-panel.open { display: flex; }
.cs-head {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: .85rem 1rem; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.02);
}
.cs-head strong { font-size: 1rem; }
.cs-head button {
  border: none; background: transparent; color: var(--muted); font-size: 1.2rem;
  line-height: 1; padding: .2rem .4rem; cursor: pointer;
}
.cs-msgs {
  flex: 1; overflow: auto; padding: .9rem; display: flex; flex-direction: column; gap: .65rem;
  background: linear-gradient(180deg, rgba(15,27,46,.35), transparent);
}
.cs-empty { color: var(--muted); text-align: center; margin: auto; font-size: .92rem; padding: 1rem; }
.cs-msg { max-width: 85%; display: grid; gap: .35rem; }
.cs-msg.user { align-self: flex-end; }
.cs-msg.admin { align-self: flex-start; }
.cs-bubble {
  padding: .65rem .8rem; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg2); white-space: pre-wrap; word-break: break-word; font-size: .93rem;
}
.cs-msg.user .cs-bubble {
  background: linear-gradient(135deg, rgba(43,183,169,.22), rgba(31,143,154,.18));
  border-color: rgba(43,183,169,.35);
}
.cs-msg.admin .cs-bubble { background: #162338; }
.cs-meta { font-size: .72rem; color: var(--muted); }
.cs-msg.user .cs-meta { text-align: right; }
.cs-thumb {
  display: block; max-width: 160px; max-height: 120px; width: auto; height: auto;
  object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in;
  background: #0a1220;
}
.cs-msg.user .cs-thumb { margin-left: auto; }
.cs-compose {
  border-top: 1px solid var(--line); padding: .7rem; display: grid; gap: .55rem; background: rgba(0,0,0,.12);
}
.cs-compose-row { display: flex; gap: .45rem; align-items: flex-end; }
.cs-compose textarea {
  flex: 1; min-height: 42px; max-height: 110px; resize: vertical; border-radius: 12px;
}
.cs-icon-btn, .cs-send {
  border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); color: #fff;
  padding: .65rem .8rem; cursor: pointer; white-space: nowrap;
}
.cs-send {
  background: linear-gradient(135deg, #2bb7a9, #1f8f9a); border: none; color: #04151a; font-weight: 700;
}
.cs-preview {
  display: none; align-items: center; gap: .6rem; color: var(--muted); font-size: .85rem;
}
.cs-preview.show { display: flex; }
.cs-preview img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.cs-preview button { border: none; background: transparent; color: var(--danger); cursor: pointer; }
.cs-login-hint { padding: 1.2rem; color: var(--muted); text-align: center; }
.cs-login-hint a { color: var(--accent2); }

/* Admin support workspace */
.cs-admin {
  display: grid; grid-template-columns: 280px 1fr; gap: 1rem; min-height: calc(100vh - 140px);
}
.cs-threads, .cs-chat {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden;
  display: flex; flex-direction: column; min-height: 560px;
}
.cs-threads-head, .cs-chat-head {
  padding: .85rem 1rem; border-bottom: 1px solid var(--line); display:flex; justify-content: space-between; align-items:center;
}
.cs-thread-list { overflow: auto; flex: 1; }
.cs-thread-item {
  display: grid; gap: .2rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line);
  cursor: pointer; color: inherit; text-decoration: none;
}
.cs-thread-item:hover, .cs-thread-item.active { background: rgba(43,183,169,.08); }
.cs-thread-item .t-title { display:flex; justify-content: space-between; gap: .5rem; font-weight: 650; }
.cs-thread-item .t-preview { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-unread {
  min-width: 18px; height: 18px; border-radius: 999px; background: var(--danger); color:#fff;
  font-size: .7rem; display:inline-flex; align-items:center; justify-content:center; padding: 0 5px;
}
.cs-chat .cs-msgs { min-height: 360px; }
.cs-chat-placeholder { margin: auto; color: var(--muted); padding: 2rem; text-align: center; }

/* Lightbox (admin enlarge) */
.cs-lightbox {
  position: fixed; inset: 0; z-index: 80; background: rgba(4,10,20,.86);
  display: none; align-items: center; justify-content: center; padding: 2rem;
}
.cs-lightbox.open { display: flex; }
.cs-lightbox img {
  max-width: min(92vw, 1100px); max-height: 88vh; object-fit: contain;
  border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.cs-lightbox-close {
  position: absolute; top: 1rem; right: 1rem; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.25); background: rgba(0,0,0,.45); color: #fff;
  font-size: 1.4rem; cursor: pointer; line-height: 1;
}
@media (max-width: 900px) {
  .cs-admin { grid-template-columns: 1fr; }
  .cs-threads { min-height: 240px; max-height: 280px; }
}

/* ---- Auth pages aligned with brand header ---- */
body.auth-page {
  background:
    radial-gradient(900px 420px at 15% -10%, rgba(43,183,169,.18), transparent 55%),
    radial-gradient(700px 380px at 90% 10%, rgba(34,211,238,.10), transparent 50%),
    var(--bg);
}
body.auth-page .wrap { margin-top: 1rem; }
.auth-shell {
  width: min(440px, 100%);
  margin: 1.2rem auto 2rem;
  animation: authIn .45s ease both;
}
.auth-brand {
  text-align: center;
  margin-bottom: 1.1rem;
}
.auth-brand h1 {
  margin: .55rem 0 .25rem;
  font-size: clamp(1.8rem, 4vw, 2.35rem);
  letter-spacing: .02em;
}
.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: .98rem;
}
.auth-logo {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  animation: logoPop .55s cubic-bezier(.2,.8,.2,1) both;
}
.auth.panel {
  max-width: none;
  margin: 0;
  background: linear-gradient(180deg, rgba(22,35,56,.95), rgba(15,27,46,.92));
  box-shadow: 0 16px 40px rgba(0,0,0,.28);
}
.auth.panel h2 { margin-top: 0; }
.auth.panel .btn.primary {
  width: 100%;
  margin-top: .2rem;
}
.auth-switch {
  margin: 1rem 0 0;
  text-align: center;
  color: var(--muted);
}
.auth-switch a { color: var(--accent2); }
@keyframes authIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes logoPop {
  from { opacity: 0; transform: scale(.92); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 640px) {
  .auth-logo { width: 64px; height: 64px; border-radius: 16px; }
}

/* ---- Home page layout redesign ---- */
body.home-page {
  --home-font: "PingFang SC", "Noto Sans SC", "Source Han Sans SC", "Segoe UI", sans-serif;
}
body.home-page .wrap {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 0 3rem;
}

.home-hero {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: clamp(2.5rem, 8vh, 5rem) 1.25rem 3.5rem;
  overflow: hidden;
}
.home-hero-bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 50% 15%, rgba(45, 196, 178, 0.22), transparent 58%),
    radial-gradient(ellipse 55% 45% at 85% 70%, rgba(34, 140, 170, 0.16), transparent 55%),
    radial-gradient(ellipse 50% 40% at 10% 85%, rgba(15, 60, 110, 0.35), transparent 50%),
    linear-gradient(180deg, rgba(8, 14, 26, 0.2) 0%, rgba(11, 18, 32, 0.95) 72%, var(--bg) 100%);
}
.home-hero-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(232, 238, 252, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 238, 252, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 40%, #000 20%, transparent 75%);
  opacity: .55;
  animation: homeGridDrift 18s linear infinite;
}
.home-hero-inner {
  width: min(720px, 100%);
  text-align: center;
  animation: homeRise .7s cubic-bezier(.2,.8,.2,1) both;
}
.home-hero-logo {
  width: clamp(72px, 12vw, 96px);
  height: clamp(72px, 12vw, 96px);
  object-fit: cover;
  border-radius: 22px;
  margin: 0 auto 1rem;
  display: block;
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 14px 36px rgba(0,0,0,.35);
  animation: homeLogoIn .75s cubic-bezier(.2,.8,.2,1) both;
}
.home-hero-brand {
  font-family: var(--home-font);
  font-weight: 800;
  font-size: clamp(2.6rem, 7vw, 4.4rem);
  letter-spacing: .04em;
  line-height: 1.05;
  margin: 0 0 .75rem;
  color: #fff;
}
.home-hero-lead {
  margin: 0 auto;
  max-width: 28rem;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 1.6;
}
.home-hero-cta {
  display: flex;
  justify-content: center;
  gap: .8rem;
  flex-wrap: wrap;
  margin-top: 1.6rem;
}
.home-hero-cta .btn {
  min-width: 8.5rem;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.home-hero-cta .btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(43, 183, 169, .28);
}
.home-hero-cta .btn.ghost:hover {
  border-color: rgba(61, 214, 198, .45);
  color: #fff;
}

.home-markets {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto 1.5rem;
  animation: homeRise .75s .12s cubic-bezier(.2,.8,.2,1) both;
}
.home-markets .section-head h2 {
  font-family: var(--home-font);
  letter-spacing: .02em;
}

.home-note {
  width: min(720px, calc(100% - 2rem));
  margin: 0 auto 1rem;
  text-align: center;
  animation: homeRise .75s .2s cubic-bezier(.2,.8,.2,1) both;
}
.home-note p {
  margin: 0;
  color: var(--muted);
  font-size: .98rem;
  letter-spacing: .01em;
}

@keyframes homeRise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes homeLogoIn {
  from { opacity: 0; transform: scale(.9); }
  to { opacity: 1; transform: none; }
}
@keyframes homeGridDrift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 56px 56px, 56px 56px; }
}

@media (max-width: 640px) {
  .home-hero {
    min-height: calc(100svh - 96px);
    padding: 2.2rem 1rem 2.6rem;
  }
  .home-hero-brand { letter-spacing: .03em; }
  .home-hero-cta .btn { width: 100%; max-width: 280px; }
}
@media (prefers-reduced-motion: reduce) {
  .home-hero-inner,
  .home-hero-logo,
  .home-markets,
  .home-note,
  .home-hero-bg::before {
    animation: none !important;
  }
}
