:root {
  color-scheme: light;
  --ink: #193448;
  --muted: #7c8d99;
  --line: #dde5e9;
  --panel: #ffffff;
  --panel-soft: #f7fafb;
  --gold: #d3a34d;
  --gold-2: #f0c96c;
  --red: #b14f47;
  --green: #278267;
  --blue: #216f9c;
  --shadow: 0 10px 30px rgba(23, 52, 72, .08);
  font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 100% 0, #dcecf5 0, transparent 34rem), #f3f6f7;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.portal-login {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(0, 1.12fr) minmax(390px, .88fr);
}

.login-scene {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 100vh;
  color: #fff;
  overflow: hidden;
  padding: 8vw;
  background:
    linear-gradient(90deg, rgba(9, 8, 7, .12), rgba(9, 8, 7, .78)),
    radial-gradient(circle at 30% 28%, rgba(255, 178, 75, .24), transparent 18rem),
    linear-gradient(150deg, #4b211c, #17110f 58%, #0b0a09);
}

.login-scene::before,
.login-scene::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 216, 148, .16);
  border-radius: 50%;
}
.login-scene::before { width: 34rem; height: 34rem; left: -11rem; top: -10rem; }
.login-scene::after { width: 20rem; height: 20rem; right: 8%; bottom: 10%; }

.scene-copy { position: relative; z-index: 1; max-width: 42rem; }
.scene-kicker { color: var(--gold-2); letter-spacing: .35em; font-size: .78rem; }
.scene-copy h1 { margin: .8rem 0; font-size: clamp(2.8rem, 6vw, 6rem); line-height: .98; }
.scene-copy p { max-width: 34rem; color: #d6cab9; line-height: 1.9; }

.login-panel {
  display: grid;
  place-items: center;
  padding: 3rem clamp(1.5rem, 6vw, 6rem);
  background: #f3f6f7;
}
.login-card { width: min(100%, 28rem); }
.login-brand { display: flex; align-items: center; gap: .9rem; margin-bottom: 3rem; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border: 1px solid rgba(255, 217, 146, .4);
  border-radius: 1rem;
  color: #251910;
  background: linear-gradient(135deg, var(--gold-2), #b8682f);
  box-shadow: 0 10px 30px rgba(225, 151, 56, .2);
  font-weight: 900;
}
.login-brand strong { display: block; font-size: 1.1rem; }
.login-brand span { color: var(--muted); font-size: .82rem; }
.login-card h2 { margin: 0; font-size: 2rem; }
.login-card > p { margin: .75rem 0 2rem; color: var(--muted); line-height: 1.7; }

.field { display: grid; gap: .55rem; margin-bottom: 1rem; }
.field span { color: #536979; font-size: .86rem; font-weight: 800; }
.field input,
.field select,
.field textarea,
.toolbar input,
.toolbar select {
  width: 100%;
  min-height: 2.85rem;
  padding: .72rem .9rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  outline: none;
  color: #28485d;
  background: #fff;
  transition: border .18s, box-shadow .18s;
}
.field input:focus,
.field select:focus,
.field textarea:focus,
.toolbar input:focus,
.toolbar select:focus {
  border-color: #3b81a9;
  box-shadow: 0 0 0 3px rgba(59, 129, 169, .11);
}

.primary,
.secondary,
.danger,
.ghost {
  min-height: 2.65rem;
  padding: .65rem 1rem;
  border-radius: .7rem;
  border: 1px solid transparent;
  color: #fff;
  background: linear-gradient(180deg, #2b7ca9, #175378);
  font-weight: 700;
}
.secondary { color: #276c94; border-color: #d4dfe4; background: #fff; }
.danger { color: #a9473f; border-color: #ebcbc7; background: #fff0ee; }
.ghost { min-height: 2.2rem; color: #547084; border-color: transparent; background: transparent; }
button:disabled { cursor: not-allowed; opacity: .45; }
.login-card .primary { width: 100%; margin-top: .5rem; }
.form-message { min-height: 1.4rem; margin-top: 1rem; color: #ff9f8e; font-size: .86rem; }
.form-message.success { color: var(--green); }

.portal-shell { display: grid; min-height: 100vh; grid-template-columns: 17.5rem minmax(0, 1fr); }
.portal-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.45rem;
  border-right: 0;
  color: #fff;
  background: linear-gradient(165deg, #081c30, #0e324f 68%, #09243d);
  box-shadow: 14px 0 34px rgba(14,45,67,.09);
}
.portal-brand { display: flex; align-items: center; gap: .75rem; padding: .35rem; }
.portal-brand strong { display: block; }
.portal-brand small { color: #7598af; }
.profile-card {
  margin: 1.6rem 0;
  padding: 1rem;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 1rem;
  background: rgba(255,255,255,.06);
}
.profile-card small { color: #83a2b7; }
.profile-card h3 { margin: .35rem 0 .2rem; }
.profile-code { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid rgba(255,255,255,.1); }
.profile-code code { color: #efcd7b; font-size: .92rem; }

.portal-nav { display: grid; gap: .35rem; }
.portal-nav button {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-height: 2.8rem;
  padding: .7rem .85rem;
  border: 0;
  border-radius: .75rem;
  color: #93aec2;
  background: transparent;
  text-align: left;
}
.portal-nav button:hover { color: #fff; background: rgba(255,255,255,.055); }
.portal-nav button.active { color: #fff; background: linear-gradient(90deg, #1c638f, #2b7da9); box-shadow: 0 8px 20px rgba(2,12,22,.34); }
.portal-nav i { width: 1.25rem; color: #b7cad8; font-style: normal; text-align: center; }
.portal-nav button.active i { color: #ffda84; }
.sidebar-bottom { margin-top: auto; }
.sidebar-bottom button { width: 100%; }
.portal-sidebar .ghost { color: #efcd7b; }
.portal-sidebar .secondary { border-color: rgba(255,255,255,.12); color: #c9d9e3; background: rgba(255,255,255,.06); }

.portal-main { min-width: 0; padding: 2rem clamp(1.1rem, 3vw, 3rem) 4rem; background: radial-gradient(circle at 100% 0, #dcecf5 0, transparent 34rem), #f3f6f7; }
.portal-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.portal-header h1 { margin: 0; font-size: clamp(1.65rem, 3vw, 2.5rem); }
.portal-header p { margin: .45rem 0 0; color: var(--muted); }
.header-actions { display: flex; align-items: center; gap: .75rem; }
.mobile-nav { display: none; }

.announcement {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: 1.2rem;
  padding: .9rem 1rem;
  border: 1px solid #d5e5ee;
  border-radius: .85rem;
  color: #587487;
  background: #edf7fb;
}
.announcement:empty { display: none; }

.portal-page { display: none; animation: page-in .2s ease-out; }
.portal-page.active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(5px); } }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stat-card,
.panel,
.product-card,
.role-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.stat-card { position: relative; min-height: 8.4rem; padding: 1.15rem; background: #fff; overflow: hidden; }
.stat-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(#2876a8, #d4a34a); }
.stat-card::after { content: ""; position: absolute; right: -2rem; bottom: -2.8rem; width: 6rem; height: 6rem; border: 1.15rem solid #eef5f8; border-radius: 50%; }
.stat-card > * { position: relative; z-index: 1; }
.stat-card small { color: var(--muted); }
.stat-card strong { display: block; margin: .7rem 0 .15rem; font-size: 1.75rem; }
.stat-card em { color: #9b6b22; font-size: .78rem; font-style: normal; }

.panel { margin-top: 1rem; padding: 1.15rem; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head p { margin: .3rem 0 0; color: var(--muted); font-size: .86rem; }
.two-column { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(18rem, .75fr); gap: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; margin-bottom: 1rem; }
.toolbar input { flex: 1 1 14rem; }
.toolbar select { flex: 0 1 10rem; }

.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: .8rem .7rem; border-bottom: 1px solid var(--line); text-align: left; font-size: .86rem; }
th { color: var(--muted); background: #fafbfc; font-weight: 800; }
tbody tr:hover { background: #f8fbfc; }
.empty { padding: 2rem; color: var(--muted); text-align: center; }
.status { display: inline-flex; align-items: center; gap: .35rem; padding: .25rem .5rem; border-radius: 2rem; color: #277d63; background: #e7f6f0; font-size: .76rem; }
.status.warn { color: #9b6a20; background: #fff4dc; }
.status.bad { color: #ad4c44; background: #f9eae8; }

.detail-list { display: grid; gap: .8rem; }
.detail-row { display: flex; justify-content: space-between; gap: 1rem; padding-bottom: .7rem; border-bottom: 1px solid var(--line); }
.detail-row span { color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(7, 23, 38, .68);
  backdrop-filter: blur(8px);
}
.modal.open { display: grid; }
.modal-card { width: min(100%, 34rem); max-height: 92vh; overflow: auto; padding: 1.35rem; border: 1px solid var(--line); border-radius: 1rem; background: #fff; box-shadow: 0 28px 90px rgba(6,20,36,.35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-head h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1rem; }

.context-strip { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(16rem, .7fr); gap: 1rem; margin-bottom: 1rem; }
.wallet-hero { position: relative; overflow: hidden; padding: 1.3rem; color: #fff; background: radial-gradient(circle at 90% 0, #286c95 0, transparent 22rem), linear-gradient(135deg, #123d5f, #081f35); }
.wallet-hero::after { content: "币"; position: absolute; right: 1rem; bottom: -2.2rem; color: rgba(255,255,255,.06); font-size: 8rem; font-weight: 900; }
.wallet-hero strong { display: block; margin: .6rem 0; font-size: 2rem; }
.wallet-hero small { color: #d9c6ac; }
.role-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .75rem; }
.role-card { padding: 1rem; box-shadow: none; cursor: pointer; }
.role-card.selected { border-color: rgba(233,180,95,.7); background: rgba(233,180,95,.09); }
.role-card strong { display: block; margin-bottom: .35rem; }
.role-card small { color: var(--muted); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; }
.product-card { position: relative; overflow: hidden; padding: 1.1rem; }
.product-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg, #2876a8, #d4a34a, transparent); }
.product-visual { height: 8rem; margin: -.25rem -.25rem .9rem; border-radius: .75rem; overflow: hidden; display: grid; place-items: center; background: linear-gradient(135deg, rgba(40,118,168,.24), rgba(212,163,74,.18)); }
.product-visual img { width: 100%; height: 100%; object-fit: cover; }
.product-visual span { font-size: 2.4rem; color: #e8c87a; font-weight: 800; }
.purchase-limits { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 1.6rem; margin: .65rem 0; }
.purchase-limits span { padding: .2rem .5rem; border: 1px solid rgba(212,163,74,.35); border-radius: 999px; color: #e8c87a; font-size: .72rem; }
.binding-actions { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .75rem; }
.product-card h3 { margin: .4rem 0; }
.product-card p { min-height: 3.2rem; color: var(--muted); line-height: 1.65; font-size: .86rem; }
.reward-list { display: flex; flex-wrap: wrap; gap: .4rem; min-height: 3rem; margin: .9rem 0; }
.reward-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .5rem .3rem .3rem; border: 1px solid var(--line); border-radius: .55rem; color: #5d7484; background: #f8fafb; font-size: .76rem; }
.reward-chip > span:last-child { display: grid; gap: .08rem; }
.reward-chip strong { color: #365b70; font-size: .74rem; }
.reward-chip small { color: #8d6a31; font-size: .7rem; }
.reward-icon { display: grid; width: 2.3rem; height: 2.3rem; flex: 0 0 2.3rem; place-items: center; overflow: hidden; border: 1px solid rgba(212,163,74,.42); border-radius: .38rem; color: #9b6b22; background: linear-gradient(145deg, #fff7df, #e8edf0); font-weight: 800; }
.reward-icon > * { grid-area: 1 / 1; }
.reward-icon img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: contain; background: #17222a; }
.campaign-reward-list { display: grid; gap: .55rem; margin: .8rem 0; }
.campaign-reward-tier { padding: .55rem; border: 1px solid var(--line); border-radius: .65rem; background: #f9fbfc; }
.campaign-reward-tier > strong { color: #365b70; font-size: .76rem; }
.campaign-reward-tier .reward-list { min-height: 0; margin: .45rem 0 0; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.price { color: #9b6b22; font-size: 1.1rem; font-weight: 800; }

.toast-stack { position: fixed; z-index: 50; right: 1rem; bottom: 1rem; display: grid; gap: .6rem; width: min(24rem, calc(100vw - 2rem)); }
.toast { padding: .85rem 1rem; border: 1px solid rgba(95,196,156,.25); border-radius: .75rem; color: #d9f7eb; background: rgba(27,71,56,.95); box-shadow: var(--shadow); }
.toast.error { color: #ffe0dc; border-color: rgba(200,85,69,.3); background: rgba(95,35,29,.96); }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-column, .context-strip { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .portal-login { grid-template-columns: 1fr; }
  .login-scene { display: none; }
  .login-panel { min-height: 100vh; }
  .portal-shell { display: block; }
  .portal-sidebar { display: none; }
  .portal-main { padding-top: 1.1rem; }
  .mobile-nav { display: block; min-width: 9rem; min-height: 2.5rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--ink); background: var(--panel); }
  .header-actions .secondary { display: none; }
  .portal-header { align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
}

@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .portal-main { padding-inline: .8rem; }
  .panel { padding: .9rem; }
  .portal-header h1 { font-size: 1.45rem; }
}
