/* wang risk dashboard — aligned with 中辉智保 / trading.html */
:root {
  --primary: #1a365d;
  --gold: #c7a02a;
  --gold-light: #e8c84a;
  --gold-dark: #a68520;
  --accent-green: #38a169;
  --accent-red: #e53e3e;
  --accent-purple: #a78bfa;
  --accent-purple-soft: rgba(167, 139, 250, 0.14);
  --bg: #0b1121;
  --bg-card: #111b2e;
  --bg-card-hover: #162440;
  --text: #edf2f7;
  --text-secondary: #bcc7d8;
  --text-muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.11);
  --surface-raised: rgba(255, 255, 255, 0.025);
  --surface-control: rgba(255, 255, 255, 0.04);
  --surface-subtle: rgba(255, 255, 255, 0.03);
  --surface-inset: rgba(0, 0, 0, 0.08);
  --surface-inset-strong: rgba(0, 0, 0, 0.15);
  --surface-hover: rgba(255, 255, 255, 0.02);
  --border-soft: rgba(255, 255, 255, 0.06);
  --sheet-cell-bg: rgba(15, 23, 42, 0.18);
  --sheet-head-bg: rgba(30, 41, 59, 0.96);
  --sheet-focus-bg: rgba(2, 6, 23, 0.45);
  --font-latin: "LatinCharter", "Charter", "Bitstream Charter", Georgia, serif;
  --font-zh: "KaiTi", "Kaiti SC", "STKaiti", "楷体", "Kai", serif;
  --font-stack: "LatinCharter", "KaiTi", "Kaiti SC", "STKaiti", "楷体", "Kai", serif;
  --page-font-size: 16px;
  --chat-fab-size: 56px;
  --chat-panel-w: 420px;
  --chat-panel-h: min(640px, calc(100vh - 96px));
  --chat-panel-h: min(640px, calc(100dvh - 96px));
  --scrollbar-size: 6px;
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.32);
  color-scheme: dark;
}

:root[data-theme="light"],
body[data-theme="light"] {
  --bg: #f7f8fb;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --text: #142033;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --border: rgba(15, 23, 42, 0.12);
  --accent-red: #c53030;
  --accent-green: #276749;
  --accent-purple-soft: rgba(99, 102, 241, 0.1);
  --gold-light: #8a6b12;
  --surface-raised: #ffffff;
  --surface-control: #f1f4f9;
  --surface-subtle: #f7f9fc;
  --surface-inset: #f8fafc;
  --surface-inset-strong: #fbfcfe;
  --surface-hover: rgba(15, 23, 42, 0.045);
  --border-soft: rgba(15, 23, 42, 0.09);
  --sheet-cell-bg: #ffffff;
  --sheet-head-bg: #eef2f7;
  --sheet-focus-bg: rgba(199, 160, 42, 0.10);
  --scrollbar-thumb: rgba(15, 23, 42, 0.22);
  --scrollbar-thumb-hover: rgba(15, 23, 42, 0.38);
  color-scheme: light;
}

:root[data-theme="dark"],
body[data-theme="dark"] {
  --scrollbar-thumb: rgba(255, 255, 255, 0.18);
  --scrollbar-thumb-hover: rgba(255, 255, 255, 0.32);
  color-scheme: dark;
}

:is(:root, body)[data-theme="dark"] :is(.wr-logo, .gm-drawer-logo, .pc-rail-logo) { background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.1); box-shadow: none; }

:root[data-font-mode="system"],
body[data-font-mode="system"] {
  --font-latin: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-zh: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

:root[data-font-mode="kaiti"],
body[data-font-mode="kaiti"] {
  --font-latin: "LatinCharter", "Charter", "Bitstream Charter", Georgia, serif;
  --font-zh: "KaiTi", "Kaiti SC", "STKaiti", "楷体", "Kai", serif;
  --font-stack: "LatinCharter", "KaiTi", "Kaiti SC", "STKaiti", "楷体", "Kai", serif;
}

@font-face {
  font-family: "LatinCharter";
  src: local("Charter"), local("Bitstream Charter"), local("Georgia");
  unicode-range: U+0000-024F, U+2000-206F;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* The UA's `[hidden] { display: none }` ties with any single class selector and
   loses to any id, so every layout class that sets display silently defeats it —
   `el.hidden = true` then changes nothing on screen. Win the cascade once here
   instead of adding a `[hidden]` companion rule to each of those classes. */
[hidden] { display: none !important; }

html {
  font-size: var(--page-font-size);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Firefox only. Chrome 121+ also understands scrollbar-color and then
   drops ::-webkit-scrollbar, which brings back the native light bar. */
@supports (-moz-appearance: none) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
  }
}

::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover,
::-webkit-scrollbar-thumb:active {
  background-color: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

body {
  font-family: var(--font-stack);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }

input, select, textarea, button {
  font-family: inherit;
  touch-action: manipulation;
}

.font-zh,
.wr-tabs button,
.wr-section-title,
.wr-title,
.matrix-card-title,
.chat-head h4,
.wr-modal-head h2,
.wr-kpi-label {
  font-family: var(--font-zh), var(--font-latin), serif;
}

.font-latin {
  font-family: var(--font-latin), serif;
}

.wr-kbd-hint { display: inline-flex; }
.wr-swipe-hint { display: none; }

@media (max-width: 768px) {
  .wr-kbd-hint { display: none; }
  .wr-swipe-hint { display: inline-flex; }
}

.wr-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 28px 88px;
}

.wr-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.wr-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.02em;
}

.wr-brand {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  align-items: start;
  flex: 1 1 780px;
  max-width: 920px;
  gap: 18px;
}

.wr-brand-copy {
  min-width: 0;
  padding-top: 2px;
}

.wr-brand-copy .wr-title {
  font-family: var(--font-latin), var(--font-zh), serif;
}

.wr-mars-brand {
  display: flex;
  align-items: baseline;
  gap: 0.3em;
  color: var(--text);
  font-family: var(--font-latin), var(--font-zh), serif;
  font-size: clamp(1.9rem, 2.5vw, 2.5rem);
  font-weight: 850;
  letter-spacing: 0.015em;
  line-height: 1.05;
}

.wr-mars-brand i {
  color: var(--text-muted);
  font-style: normal;
  font-weight: 400;
}

.wr-mars-brand em {
  color: var(--gold-light);
  font-style: normal;
  letter-spacing: 0.025em;
}

.wr-logo {
  width: 76px;
  height: 76px;
  border-radius: 19px;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 7px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.24);
}

img.wr-logo:is([src*="tianshu_logo"], [src*="sinan-static/icon"]) { padding: 0; background: none; border: 0; }

.wr-company {
  color: var(--gold-light);
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.wr-company i {
  font-style: normal;
  font-weight: 400;
  margin: 0 0.15em;
}

.wr-company em,
.wr-mars-brand em {
  font-style: normal;
}

.wr-company .font-latin,
.wr-title .font-latin,
.wr-mars-brand .font-latin {
  font-family: var(--font-latin), serif;
  font-style: normal;
}

.wr-company .font-zh,
.wr-mars-brand .font-zh {
  font-family: var(--font-zh), serif;
}

.wr-subtitle {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 4px;
}

.wr-logo-link {
  display: block;
  width: fit-content;
  border-radius: 19px;
  line-height: 0;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.wr-logo-link:hover {
  transform: translateY(-1px);
}

.wr-logo-link:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* OpenClaw-style chrome: no company / page badge in the topbar.
   The rail (desktop) and hamburger drawer (H5) already carry those marks. */
.wr-dash > .wr-topbar .wr-logo-link,
.wr-dash > .wr-topbar .wr-page-icon,
.st-shell > .wr-topbar .wr-logo-link,
.st-shell > .wr-topbar .wr-page-icon {
  display: none;
}

.wr-dash > .wr-topbar .wr-brand,
.st-shell > .wr-topbar .wr-brand {
  grid-template-columns: minmax(0, 1fr);
}

.st-shell > .wr-topbar .wr-company {
  display: none;
}

.wr-page-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
  max-width: 420px;
}

.wr-page-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  min-height: 66px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.055), var(--surface-raised));
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.wr-page-card:hover {
  border-color: rgba(199, 160, 42, 0.55);
  background: linear-gradient(145deg, rgba(199, 160, 42, 0.14), var(--surface-subtle));
  transform: translateY(-1px);
}

.wr-page-card[hidden] {
  display: none !important;
}

.wr-page-card > strong {
  display: grid;
  place-items: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(199, 160, 42, 0.45);
  border-radius: 9px;
  background: linear-gradient(135deg, rgba(199, 160, 42, 0.24), rgba(199, 160, 42, 0.06));
  color: var(--gold-light);
  font-size: 0.92rem;
  line-height: 1;
}

.wr-page-card > strong.font-zh {
  font-family: var(--font-zh), serif;
  font-size: 1.05rem;
  font-weight: 700;
}

.wr-page-card > strong.font-latin {
  font-family: var(--font-latin), serif;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.wr-page-card > strong.wr-page-card-img {
  padding: 3px;
}

.wr-page-card > strong.wr-page-card-img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.wr-page-card > strong.wr-page-card-img svg {
  width: 20px;
  height: 20px;
  display: block;
}

.wr-page-card > span {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.wr-page-card b {
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 850;
  line-height: 1.15;
}

.wr-page-card b .font-latin {
  font-family: var(--font-latin), serif;
  font-style: normal;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.wr-page-card b .font-zh {
  font-family: var(--font-zh), serif;
  font-weight: 850;
}

.wr-page-card small {
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 650;
  line-height: 1.4;
}

.wr-meta {
  display: none;
  grid-column: 2;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.wr-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 750;
  border: 1px solid var(--border);
  background: var(--surface-control);
  color: var(--text-muted);
}

.wr-chip.gold {
  border-color: rgba(199, 160, 42, 0.45);
  background: rgba(199, 160, 42, 0.14);
  color: var(--gold-light);
}

.wr-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.wr-actions .wr-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.wr-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.wr-theme-toggle:hover {
  background: var(--surface-control);
  border-color: var(--border);
}

.wr-theme-toggle:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 2px;
}

.wr-theme-icon {
  font-size: 17px;
  line-height: 1;
  pointer-events: none;
  user-select: none;
  animation: wrThemeIconIn 0.28s ease;
}

@keyframes wrThemeIconIn {
  from { opacity: 0; transform: rotate(-45deg) scale(0.6); }
  to { opacity: 1; transform: rotate(0) scale(1); }
}

.wr-actions .wr-btn.is-busy {
  pointer-events: none;
}

.wr-actions .wr-btn.is-busy::before {
  content: "";
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-top-color: #fff;
  border-radius: 50%;
  animation: wrSpin 0.8s linear infinite;
}

.wr-user-menu {
  position: relative;
}

.wr-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-control);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 850;
  cursor: pointer;
}

.wr-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
}

.wr-user-avatar.has-photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
  overflow: hidden;
}

.wr-avatar-preview {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  margin: 4px auto 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  font-size: 2rem;
  font-weight: 750;
}

.wr-avatar-preview.has-photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: transparent;
  overflow: hidden;
}

.wr-avatar-crop {
  margin: 4px auto 12px;
}

.wr-avatar-stage {
  position: relative;
  width: min(240px, 100%, 36vh);
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 14px;
  /* Match canvas letterbox so contain-fit preview matches the uploaded PNG. */
  background: #fff;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  touch-action: none;
  overscroll-behavior: none;
  cursor: grab;
  user-select: none;
}

.wr-avatar-stage.is-panning {
  cursor: grabbing;
}

.wr-avatar-stage-img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  height: auto;
  transform: translate(-50%, -50%);
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.wr-avatar-stage-mask {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    circle closest-side at 50% 50%,
    transparent 99%,
    color-mix(in srgb, #000 46%, transparent) 100%
  );
}

.wr-avatar-stage-mask::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 2px solid color-mix(in srgb, #fff 82%, var(--gold, #c7a02a));
  border-radius: 50%;
  box-sizing: border-box;
}

.wr-avatar-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(240px, 100%, 36vh);
  margin: 10px auto 0;
}

.wr-avatar-zoom-btn {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  background: var(--surface-control, color-mix(in srgb, var(--bg-card, #111b2e) 88%, #fff));
  color: var(--text, #edf2f7);
  font-size: 1.15rem;
  line-height: 1;
  font-weight: 700;
  cursor: pointer;
}

.wr-avatar-zoom-btn:hover {
  border-color: var(--gold, #c7a02a);
}

.wr-avatar-zoom-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.wr-avatar-zoom input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--gold, #c7a02a);
}

.wr-user-panel {
  --wr-user-control-h: 40px;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 220px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.wr-user-panel a,
.wr-user-panel button,
.wr-user-setting {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
}

.wr-user-panel a[hidden],
.wr-user-panel button[hidden] {
  display: none !important;
}

.wr-user-setting {
  cursor: default;
}

.wr-user-setting > span {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 850;
}

.wr-user-setting select {
  width: 100%;
  height: var(--wr-user-control-h);
  min-height: var(--wr-user-control-h);
  padding: 0 32px 0 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--surface-control);
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 2px), calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 800;
  line-height: 1.2;
  appearance: none;
  -webkit-appearance: none;
}

.wr-user-theme {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.wr-theme-seg {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 3px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--surface-inset-strong);
  box-sizing: border-box;
}

.wr-theme-seg::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: inherit;
  background: var(--bg-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), 0 0 0 1px var(--border-soft);
  transition: transform 0.22s cubic-bezier(0.25, 0.1, 0.25, 1);
  pointer-events: none;
}

:is(:root, body)[data-theme="light"] .wr-theme-seg::before {
  transform: translateX(100%);
}

.wr-theme-seg-btn,
.wr-user-panel .wr-theme-seg-btn,
.pc-user-panel .wr-theme-seg-btn {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0 6px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  cursor: pointer;
  box-shadow: none;
  transition: color 0.16s ease;
}

.wr-theme-seg-ico {
  display: inline-flex;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  pointer-events: none;
}

.wr-theme-seg-ico svg,
.wr-theme-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.wr-theme-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.wr-theme-seg-txt {
  pointer-events: none;
  line-height: 1;
}

.wr-theme-seg-btn:hover,
.wr-user-panel .wr-theme-seg-btn:hover,
.pc-user-panel .wr-theme-seg-btn:hover {
  background: transparent;
  color: var(--text-secondary);
}

.wr-theme-seg-btn.is-active,
.wr-theme-seg-btn[aria-pressed="true"],
.wr-user-panel .wr-theme-seg-btn.is-active,
.wr-user-panel .wr-theme-seg-btn[aria-pressed="true"],
.pc-user-panel .wr-theme-seg-btn.is-active,
.pc-user-panel .wr-theme-seg-btn[aria-pressed="true"] {
  background: transparent;
  border: 0;
  color: var(--text);
  box-shadow: none;
}

.wr-theme-seg-btn.is-active:hover,
.wr-theme-seg-btn[aria-pressed="true"]:hover,
.wr-user-panel .wr-theme-seg-btn.is-active:hover,
.wr-user-panel .wr-theme-seg-btn[aria-pressed="true"]:hover,
.pc-user-panel .wr-theme-seg-btn.is-active:hover,
.pc-user-panel .wr-theme-seg-btn[aria-pressed="true"]:hover {
  background: transparent;
  color: var(--text);
}

.wr-user-panel-divider {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}

.wr-user-panel a:hover,
.wr-user-panel > button:hover {
  background: rgba(199, 160, 42, 0.14);
  color: var(--gold-light);
}

.wr-user-panel > button.avatar-upload-entry {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wr-user-panel .pc-user-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--text-muted);
}

.wr-user-panel .pc-user-ico svg {
  display: block;
  width: 100%;
  height: 100%;
}

.wr-user-panel > button.wr-sso-bind {
  color: var(--gold-light);
}

.wr-user-panel > button.wr-sso-bind:disabled {
  opacity: 0.6;
  cursor: default;
}

.wr-user-panel .wr-sso-bound {
  display: block;
  padding: 9px 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.wr-sso-bound-tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.wr-sso-toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  z-index: 90;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: min(520px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.55;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.wr-sso-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.wr-sso-toast.is-error {
  border-color: rgba(214, 84, 84, 0.55);
}

.wr-sso-toast button {
  flex: none;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.3;
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  .wr-sso-toast {
    transition: none;
  }
}

.wr-model-picker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 10px 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-control);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 800;
}

.wr-model-picker select {
  min-height: 32px;
  max-width: 190px;
  padding: 5px 28px 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.wr-btn {
  border: 1px solid rgba(199, 160, 42, 0.45);
  background: rgba(199, 160, 42, 0.16);
  color: var(--gold-light);
  border-radius: 999px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.wr-btn:hover {
  background: rgba(199, 160, 42, 0.26);
  border-color: var(--gold-light);
}

.wr-btn:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.wr-btn-gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  border: none;
}

.wr-btn-ghost {
  background: var(--surface-control);
  border-color: var(--border);
  color: var(--text-secondary);
}

/* ---------- Current-page badge, shown only on the collapsed phone topbar ---------- */
.wr-page-icon {
  display: none;
}

@media (max-width: 768px) {
  .wr-page-icon {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(199, 160, 42, 0.45);
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(199, 160, 42, 0.24), rgba(199, 160, 42, 0.06));
    color: var(--gold-light);
  }

  .wr-page-icon svg {
    width: 24px;
    height: 24px;
  }

  .wr-page-icon img {
    width: 27px;
    height: 27px;
    object-fit: contain;
  }

  .wr-page-icon-glyph {
    font-family: var(--font-zh), serif;
    font-size: 19px;
    font-weight: 800;
    line-height: 1;
  }
}

/* ---------- Topbar nav buttons: icon + label, icon-only on small screens ---------- */
.wr-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  text-decoration: none;
  white-space: nowrap;
}

.wr-nav-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  pointer-events: none;
}

.wr-nav-ico svg {
  width: 100%;
  height: 100%;
  display: block;
}

.wr-nav-ico img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* 积分余额徽标: sits inside the nav entry, filled in once the API answers */
.wr-points-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(199, 160, 42, 0.16);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.gm-drawer-section .wr-points-badge {
  margin-left: auto;
}

.pc-rail-item .pc-rail-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  height: 16px;
  min-width: 16px;
  padding: 0 4px;
  font-size: 10px;
  background: var(--gold);
  color: #1a1405;
}

[data-im-unread] {
  background: #c0392b;
  color: #fff;
}

.pc-rail-item [data-im-unread] {
  background: #c0392b;
  color: #fff;
}

/* Single-glyph badge, e.g. 「知」 for the knowledge base */
.wr-nav-ico-glyph {
  font-family: var(--font-zh), serif;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  border: 1.4px solid currentColor;
  border-radius: 7px;
  padding-top: 1px;
}

@media (max-width: 1024px) {
  /* Match the hamburger breakpoint, not only the 768px icon-row. */
  .wr-dash .wr-page-legend,
  .wr-dash .wr-user-menu {
    display: none;
  }

  .wr-nav-btn {
    gap: 0;
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
  }

  .wr-nav-btn .wr-nav-label {
    display: none;
  }

  /* The button collapses to a 44px circle, so the balance rides on its corner. */
  .wr-nav-btn {
    position: relative;
  }

  .wr-nav-btn .wr-points-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    height: 16px;
    min-width: 16px;
    padding: 0 4px;
    font-size: 10px;
    background: var(--gold);
    color: #1a1405;
  }

  .wr-nav-ico {
    width: 24px;
    height: 24px;
  }

  /* Icon-only circle: drop the inner badge border so the glyph can truly center. */
  .wr-nav-btn .wr-nav-ico-glyph {
    width: auto;
    height: auto;
    border: 0;
    border-radius: 0;
    padding: 0;
    font-size: 1.05rem;
    line-height: 1;
    transform: translateY(1px);
  }

  /* Icon-only: the busy spinner replaces the icon instead of sitting beside it. */
  .wr-nav-btn.is-busy .wr-nav-ico {
    display: none;
  }

  .wr-actions .wr-nav-btn.is-busy::before {
    margin-right: 0;
  }
}

.wr-icon-action {
  width: 44px;
  padding-inline: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.wr-calendar-icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes wrSpin {
  to { transform: rotate(360deg); }
}

.wr-kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.wr-kpi > * {
  min-width: 0;
}

.wr-kpi-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--surface-raised);
}

.wr-kpi-card.gain {
  border-color: rgba(229, 62, 62, 0.28);
  background: linear-gradient(145deg, rgba(229,62,62,0.10), rgba(229,62,62,0));
}

.wr-kpi-card.loss {
  border-color: rgba(56, 161, 105, 0.28);
  background: linear-gradient(145deg, rgba(56,161,105,0.10), rgba(56,161,105,0));
}

.wr-kpi-card.flash-up { animation: wrPriceFlashUp 0.75s ease-out; }
.wr-kpi-card.flash-down { animation: wrPriceFlashDown 0.75s ease-out; }

.wr-kpi-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 820;
  letter-spacing: 0.015em;
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wr-kpi-value {
  max-width: 100%;
  font-size: clamp(1rem, 0.72rem + 0.72vw, 1.35rem);
  line-height: 1.28;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.wr-price-section {
  margin: 0 0 18px;
}

.wr-price-section.collapsed {
  margin-bottom: 12px;
}

.wr-price-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.wr-price-title-toggle {
  cursor: pointer;
  border-radius: 8px;
}

.wr-price-title-toggle:hover,
.wr-price-title-toggle:focus-visible {
  color: var(--gold-light);
  outline: none;
}

.wr-price-head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.wr-collapse-btn {
  border: 1px solid var(--border);
  background: var(--surface-control);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.74rem;
  font-weight: 850;
  cursor: pointer;
}

.wr-collapse-btn:hover {
  color: var(--gold-light);
  border-color: rgba(199, 160, 42, 0.45);
}

.wr-price-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}

.wr-price-board.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.wr-price-card {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 10px 11px;
  background: linear-gradient(145deg, rgba(255,255,255,0.045), var(--surface-raised));
}

.wr-price-card::after {
  content: "";
  position: absolute;
  right: -20px;
  top: -22px;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: rgba(199, 160, 42, 0.08);
  pointer-events: none;
}

.wr-price-card.gain {
  border-color: rgba(229, 62, 62, 0.28);
  background: linear-gradient(145deg, rgba(229,62,62,0.10), rgba(229,62,62,0));
}

.wr-price-card.loss {
  border-color: rgba(56, 161, 105, 0.28);
  background: linear-gradient(145deg, rgba(56,161,105,0.10), rgba(56,161,105,0));
}

.wr-price-card.flash-up { animation: wrPriceFlashUp 0.75s ease-out; }
.wr-price-card.flash-down { animation: wrPriceFlashDown 0.75s ease-out; }

@keyframes wrPriceFlashUp {
  0% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.72); transform: translateY(-1px); }
  100% { box-shadow: 0 0 0 18px rgba(229, 62, 62, 0); transform: translateY(0); }
}

@keyframes wrPriceFlashDown {
  0% { box-shadow: 0 0 0 0 rgba(56, 161, 105, 0.72); transform: translateY(1px); }
  100% { box-shadow: 0 0 0 18px rgba(56, 161, 105, 0); transform: translateY(0); }
}

.wr-price-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
  position: relative;
  z-index: 1;
}

.wr-price-top > div {
  min-width: 0;
}

.wr-price-name {
  font-weight: 900;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wr-price-symbol {
  color: var(--text-secondary);
  font-family: var(--font-latin), ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.025em;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.wr-price-source {
  flex: 0 0 auto;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  background: var(--surface-control);
  font-size: 0.64rem;
  font-weight: 750;
}

.wr-price-main {
  margin-top: 6px;
  max-width: 100%;
  font-size: clamp(0.96rem, 0.82rem + 0.36vw, 1.08rem);
  line-height: 1.15;
  font-weight: 900;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.wr-price-change {
  margin-top: 3px;
  font-size: 0.74rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  word-break: break-word;
  position: relative;
  z-index: 1;
}

.wr-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  margin-bottom: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.wr-tabs::-webkit-scrollbar { display: none; }

.wr-tabs button {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  flex: 0 0 auto;
  scroll-snap-align: start;
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-weight: 850;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}

.wr-tabs button.active {
  border-color: rgba(199, 160, 42, 0.55);
  background: rgba(199, 160, 42, 0.16);
  color: var(--gold-light);
}

.wr-toolbar {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.wr-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.wr-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.wr-toggle-track {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-control);
  transition: background 0.16s, border-color 0.16s;
}

.wr-toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--text-secondary);
  transition: transform 0.16s, background 0.16s;
}

.wr-toggle input:checked + .wr-toggle-track {
  border-color: rgba(199, 160, 42, 0.62);
  background: rgba(199, 160, 42, 0.22);
}

.wr-toggle input:checked + .wr-toggle-track::after {
  transform: translateX(18px);
  background: var(--gold-light);
}

.wr-lookback {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wr-lookback input[type="range"] { width: 140px; accent-color: var(--gold); }

.wr-panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  background: var(--bg-card);
  min-height: 520px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.wr-section-title {
  font-size: 1.08rem;
  font-weight: 850;
  color: var(--text);
  margin-bottom: 6px;
}

.wr-muted {
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.wr-callout {
  background: rgba(199, 160, 42, 0.08);
  border-left: 3px solid var(--gold);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 10px 0 14px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.wr-metric-guide {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-subtle);
  padding: 12px;
  margin: 14px 0;
}

.wr-guide-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 900;
  cursor: pointer;
  text-align: left;
}

.wr-guide-toggle span {
  color: var(--gold-light);
}

.wr-guide-toggle em {
  flex: 0 0 auto;
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.wr-guide-body {
  margin-top: 10px;
}

.wr-metric-guide.collapsed .wr-guide-body {
  display: none;
}

.wr-guide-intro {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.7;
}

.wr-guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
}

.wr-guide-grid div {
  display: grid;
  gap: 3px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 9px 10px;
  background: var(--surface-inset);
}

.wr-guide-grid strong {
  color: var(--gold-light);
  font-size: 0.82rem;
}

.wr-guide-grid span,
.wr-chart-note {
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.55;
}

.wr-guide-grid span em {
  display: inline-block;
  margin-right: 6px;
  color: var(--gold);
  font-style: normal;
  font-weight: 850;
}

.wr-data-card {
  position: relative;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: var(--surface-inset);
  margin: 12px 0;
  overflow: hidden;
}

.wr-data-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px 0;
}

.wr-data-card-head > div:first-child {
  min-width: 0;
}

.wr-data-card-head strong {
  display: block;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 900;
}

.wr-data-card-head span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.45;
}

.wr-data-card-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.wr-card-font-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.wr-card-font-control input[type="range"] {
  width: 112px;
  accent-color: var(--gold);
}

.wr-card-font-control em {
  min-width: 34px;
  color: var(--gold-light);
  font-style: normal;
  text-align: right;
}

.wr-expand-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: var(--surface-control);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-weight: 850;
  cursor: pointer;
}

.wr-expand-btn:hover {
  color: var(--gold-light);
  border-color: rgba(199, 160, 42, 0.45);
}

.wr-data-card-body .wr-table-wrap {
  margin: 8px 0 0;
}

.wr-table-wrap {
  overflow-x: auto;
  margin: 12px 0;
  -webkit-overflow-scrolling: touch;
}

.adm-view > .wr-table-wrap { max-height: min(70dvh, 720px); overflow: auto; }
.adm-view > .wr-table-wrap thead th { position: sticky; top: 0; z-index: 2; background: var(--bg-card-hover, var(--bg-card)); }
.wr-table th.wr-sticky-actions, .wr-table td.wr-sticky-actions { position: sticky; right: 0; background: var(--bg-card); box-shadow: -2px 0 0 var(--border); }
.wr-table th.wr-sticky-actions { z-index: 3; background: var(--bg-card-hover, var(--bg-card)); }

table.wr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--card-table-font-size, 0.86rem);
}

.wr-table th, .wr-table td {
  border-bottom: 1px solid var(--border);
  padding: 9px 8px;
  text-align: left;
  white-space: nowrap;
}

.wr-table th {
  color: var(--text-secondary);
  font-weight: 850;
  font-size: var(--card-table-head-font-size, 0.8rem);
  letter-spacing: 0.01em;
}

.wr-table tr:hover td { background: var(--surface-hover); }

.wr-contract-code {
  color: var(--text-secondary);
  font-family: var(--font-latin), ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88em;
  font-weight: 750;
  letter-spacing: 0.025em;
}

.wr-sort-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
}

.wr-sort-btn.active {
  color: var(--gold-light);
}

.wr-live-cell {
  display: inline-block;
  border-radius: 6px;
  padding: 1px 4px;
  margin: -1px -4px;
}

.wr-table .wr-live-cell.trend-up {
  color: var(--accent-red);
  font-weight: 900;
}

.wr-table .wr-live-cell.trend-down {
  color: var(--accent-green);
  font-weight: 900;
}

.wr-live-cell.flash-up { animation: wrPriceFlashUp 0.75s ease-out; }
.wr-live-cell.flash-down { animation: wrPriceFlashDown 0.75s ease-out; }

.text-green { color: var(--accent-green); }
.text-red { color: var(--accent-red); }
.text-gold { color: var(--gold-light); }
.text-yellow { color: #f6c343; }
.text-soft-yellow { color: #f6e58d; }
.num { font-variant-numeric: tabular-nums; }
.num.gain, .gain { color: var(--accent-red); }
.num.loss, .loss { color: var(--accent-green); }
.dir-long {
  color: var(--accent-red);
  font-weight: 900;
}
.dir-short {
  color: var(--accent-green);
  font-weight: 900;
}

/* 知识库 / OpenClaw 多空立场：中国市场红涨绿跌 */
.md-stance {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: baseline;
}
.md-stance-dot {
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: currentColor;
  flex: 0 0 auto;
}
.md-stance-long { color: var(--accent-red); }
.md-stance-short { color: var(--accent-green); }
.md-stance-flat { color: var(--text-muted, #94a3b8); }
.md-stance-split { color: var(--gold, #c7a02a); }
.risk-extreme {
  color: var(--accent-red);
  font-weight: 900;
}
.risk-high {
  color: #f6c343;
  font-weight: 900;
}
.risk-medium {
  color: #f6e58d;
  font-weight: 850;
}
.risk-low {
  color: var(--accent-green);
  font-weight: 850;
}

:is(:root, body)[data-theme="light"] .text-yellow,
:is(:root, body)[data-theme="light"] .risk-high {
  color: #a16207;
}

:is(:root, body)[data-theme="light"] .text-soft-yellow,
:is(:root, body)[data-theme="light"] .risk-medium {
  color: #b45309;
}

:is(:root, body)[data-theme="light"] .md-stance-flat {
  color: #64748b;
}

:is(:root, body)[data-theme="light"] .md-stance-split {
  color: #8a6b12;
}

@media (max-width: 640px) {
  .md-stance-dot {
    width: 0.5em;
    height: 0.5em;
  }
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 14px;
  margin: 14px 0;
}

.chart-box {
  width: 100%;
  height: 360px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-inset-strong);
  padding: 4px;
}

.wr-chart-note {
  margin: -6px 4px 8px;
}

.wr-chart-note i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: -1px;
}

.wr-chart-note span {
  margin-right: 12px;
  white-space: nowrap;
}

.chart-tall { height: 420px; }
.chart-medium { height: 300px; }
.chart-small { height: 220px; }

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.wr-gauge-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-raised);
  padding: 10px 12px 12px;
}

.wr-gauge-card .chart-box {
  border: none;
  background: transparent;
  padding: 0;
}

.wr-gauge-title {
  color: var(--text);
  font-weight: 900;
  font-size: 0.86rem;
  margin-bottom: 4px;
}

.wr-scenario {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--surface-raised);
}

.wr-scenario h4 {
  font-size: 0.95rem;
  font-weight: 850;
  color: var(--gold-light);
  margin-bottom: 6px;
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.matrix-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(145deg, var(--surface-subtle) 0%, var(--surface-inset) 100%);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.matrix-card:hover {
  border-color: rgba(199, 160, 42, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
}

.matrix-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.matrix-card-title { font-size: 1rem; font-weight: 850; }

.matrix-score-badge {
  font-size: 1.1rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(199, 160, 42, 0.15);
  color: var(--gold-light);
  border: 1px solid rgba(199, 160, 42, 0.35);
}

.matrix-dim-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin: 10px 0;
}

.matrix-dim-chip {
  text-align: center;
  padding: 6px 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.72rem;
  background: var(--surface-subtle);
}

.matrix-dim-chip .sym {
  display: block;
  font-size: 1.1rem;
  font-weight: 900;
  line-height: 1.2;
}

.matrix-dim-chip.pass .sym { color: var(--accent-green); }
.matrix-dim-chip.fail .sym { color: var(--accent-red); }
.matrix-dim-chip.neutral .sym { color: var(--text-muted); }
.matrix-dim-chip.manual { box-shadow: inset 0 0 0 1px rgba(199, 160, 42, 0.5); }

.matrix-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-top: 8px;
}

.matrix-tag {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
}
.matrix-tag.held { background: rgba(199, 160, 42, 0.22); color: var(--gold-light); }
.matrix-tag.watch { background: rgba(96, 165, 250, 0.20); color: #93c5fd; }

:is(:root, body)[data-theme="light"] .matrix-tag.watch {
  color: #1d4ed8;
}

.sc-mark { display: inline-block; min-width: 16px; text-align: center; font-weight: 800; }
.sc-mark.pass { color: var(--accent-green); }
.sc-mark.fail { color: var(--accent-red); }
.sc-mark.neutral { color: var(--text-muted); }
.matrix-framework-editor {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-raised);
}
.matrix-framework-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.matrix-framework-head strong { color: var(--gold); }
.matrix-framework-head p { margin: 4px 0 0; }
.framework-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.framework-weight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.framework-weight-item {
  display: grid;
  grid-template-columns: 1fr 58px 14px;
  gap: 6px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.78rem;
}
.framework-weight-item input,
.framework-text-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-control);
  color: var(--text);
  padding: 6px 8px;
  font-family: inherit;
}
.framework-weight-item em {
  font-style: normal;
  color: var(--text-muted);
}
.framework-weight-hint {
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 0.8rem;
}
.framework-weight-hint.ok {
  color: var(--accent-green);
  background: rgba(56, 161, 105, 0.08);
}
.framework-weight-hint.warn {
  color: var(--accent-red);
  background: rgba(229, 62, 62, 0.08);
}
.framework-table-scroll { overflow-x: auto; }
.framework-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}
.framework-table th,
.framework-table td {
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: left;
  vertical-align: middle;
  font-size: 0.78rem;
}
.framework-table th {
  color: var(--text-muted);
  font-weight: 800;
}
.framework-mark-group {
  display: inline-flex;
  gap: 4px;
}
.framework-mark-group button {
  min-width: 30px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface-subtle);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 5px;
}
.framework-mark-group button.active.pass { border-color: var(--accent-green); color: var(--accent-green); }
.framework-mark-group button.active.fail { border-color: var(--accent-red); color: var(--accent-red); }
.framework-mark-group button.active.neutral { border-color: var(--text-muted); color: var(--text-secondary); }
.framework-text-input.wide { min-width: 190px; }
.matrix-dir { font-weight: 800; }
.matrix-dir.long { color: var(--accent-red); }
.matrix-dir.short { color: var(--accent-green); }
.matrix-dir.flat { color: var(--text-muted); }

.matrix-ai {
  margin-top: 14px;
  border: 1px solid rgba(199, 160, 42, 0.28);
  border-radius: 10px;
  padding: 12px 14px;
  background: rgba(199, 160, 42, 0.05);
}
.matrix-ai-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.matrix-ai-head strong { color: var(--gold-light); font-size: 0.92rem; }
.matrix-ai-body { font-size: 0.85rem; line-height: 1.7; }
.matrix-ai-body p { margin: 0 0 6px; }
.matrix-ai-body p:last-child { margin-bottom: 0; }
.matrix-ai-body strong { color: var(--gold-light); }
.matrix-ai-body .ai-list { margin: 0; padding-left: 20px; }
.matrix-ai-body .ai-list li { margin: 0 0 6px; }
.matrix-ai-body .ai-list li:last-child { margin-bottom: 0; }
.matrix-ai-meta { margin-top: 8px; font-size: 0.68rem; }

.wr-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.wr-modal.hidden { display: none; }

/* 没有显式遮罩子元素时兜底（知识库/文库分享、版本对比等） */
.wr-modal:not(:has(.wr-modal-backdrop)) {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
}

.wr-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.wr-modal-sheet {
  position: relative;
  width: min(720px, 100%);
  max-height: 88vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.22s ease;
}

@media (min-width: 768px) {
  .wr-modal { align-items: center; }
  .wr-modal-sheet { border-radius: 18px; max-height: 85vh; }
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.wr-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.wr-modal-head h2 {
  font-size: 1.1rem;
  font-weight: 850;
  color: var(--gold-light);
}

.wr-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  flex: 1;
}

.wr-upload-status {
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid rgba(199, 160, 42, 0.28);
  border-radius: 12px;
  background: rgba(199, 160, 42, 0.10);
  color: var(--gold-light);
  font-size: 0.84rem;
  font-weight: 800;
}

.wr-upload-import {
  display: grid;
  gap: 14px;
}

.wr-upload-import.hidden {
  display: none;
}

.wr-upload-import-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 240px);
  gap: 14px;
  align-items: stretch;
}

.wr-upload-import-head h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 1rem;
}

.wr-upload-file-add {
  min-height: 118px;
  margin: 0;
  border-style: dashed;
}

.wr-upload-file-list {
  display: grid;
  gap: 10px;
}

.wr-upload-file-empty {
  padding: 16px;
  border: 1px dashed var(--border-soft);
  border-radius: 12px;
  background: var(--surface-inset);
}

.wr-upload-file-item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-inset);
}

.wr-upload-file-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid rgba(199, 160, 42, 0.34);
  background: rgba(199, 160, 42, 0.10);
  color: var(--gold-light);
  font-weight: 900;
}

.wr-upload-file-main {
  min-width: 0;
}

.wr-upload-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-weight: 800;
}

.wr-modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.wr-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.dim-editor {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--surface-raised);
}

.dim-editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dim-editor-head strong { font-weight: 850; }

.dim-meta {
  font-size: 0.76rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dim-explain {
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  background: rgba(232, 200, 74, 0.04);
  font-size: 0.78rem;
  line-height: 1.6;
}

.dim-explain-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
}

.dim-explain-row:last-child { margin-bottom: 0; }

.dim-explain-tag {
  flex: 0 0 auto;
  min-width: 52px;
  font-weight: 800;
  color: var(--gold);
  font-size: 0.7rem;
  padding-top: 1px;
}

.dim-explain-tag.verdict.pass { color: var(--accent-green); }
.dim-explain-tag.verdict.fail { color: var(--accent-red); }
.dim-explain-tag.verdict.neutral { color: var(--text-muted); }

.dim-verdict.pass { color: var(--accent-green); }
.dim-verdict.fail { color: var(--accent-red); }
.dim-verdict.neutral { color: var(--text-secondary); }

.dim-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dim-fact {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--surface-control);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.dim-fact em {
  font-style: normal;
  color: var(--text-muted);
  font-size: 0.68rem;
}

.dim-slider { width: 100%; accent-color: var(--gold); }

.dim-tri {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.dim-tri button {
  flex: 1;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 800;
}

.dim-tri button.active.pass { border-color: var(--accent-green); color: var(--accent-green); }
.dim-tri button.active.fail { border-color: var(--accent-red); color: var(--accent-red); }
.dim-tri button.active.neutral { border-color: var(--text-muted); color: var(--text-muted); }

.chat-fab {
  position: fixed;
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: var(--chat-fab-size);
  height: var(--chat-fab-size);
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease;
}

.chat-fab:hover { transform: translateY(-2px); }
.chat-fab[data-open="1"] {
  background: var(--bg-card);
  color: var(--gold);
  border: 1px solid var(--border);
}

.chat-panel {
  position: fixed;
  right: calc(24px + env(safe-area-inset-right, 0px));
  bottom: calc(24px + var(--chat-fab-size) + 12px + env(safe-area-inset-bottom, 0px));
  width: var(--chat-panel-w);
  height: var(--chat-panel-h);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: chatSlideUp 0.18s ease;
}

.chat-panel.hidden { display: none; }

@keyframes chatSlideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.chat-head h4 {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gold-light);
  flex: 1;
}

.chat-head-actions button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.chat-empty .examples {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-empty .examples button {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
  animation: fadeIn 0.18s ease;
}

.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; }

.chat-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-msg.user .chat-bubble {
  background: var(--accent-purple-soft);
  border-color: rgba(167, 139, 250, 0.25);
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}

.chat-form input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.88rem;
}

body.wr-modal-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.chat-send {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
}

@media (max-width: 768px) {
  .wr-shell {
    padding: 14px 12px calc(88px + env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }

  /* Phone topbar collapses to a single scrollable icon row:
     logo + page icon + actions; account menu sticks on the right. */
  .wr-topbar {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .wr-topbar::-webkit-scrollbar { display: none; }
  .wr-brand { display: flex; align-items: center; width: auto; flex: 0 0 auto; max-width: none; gap: 8px; }
  .wr-logo { width: 40px; height: 40px; border-radius: 11px; padding: 3px; }
  .wr-logo-link { border-radius: 11px; }
  .wr-brand .wr-company,
  .wr-brand .wr-subtitle { display: none; }
  .wr-brand .wr-title,
  .wr-brand .wr-mars-brand { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .wr-brand-copy { padding-top: 0; flex: 0 0 auto; }

  .wr-page-legend { display: flex; flex-wrap: nowrap; gap: 8px; margin-top: 0; max-width: none; flex: 0 0 auto; }
  .wr-page-card {
    width: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    align-items: center;
    flex: 0 0 44px;
  }
  .wr-page-card > span { display: none; }
  .wr-page-card > strong {
    display: grid;
    place-items: center;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 0;
    background: none;
    font-size: 1.05rem;
    line-height: 1;
  }
  /* CJK serif glyphs sit optically high in the em-box; nudge down to match SVG icons. */
  .wr-page-card > strong.font-zh,
  .wr-page-icon-glyph,
  .wr-user-avatar {
    transform: translateY(1px);
  }
  .wr-page-card > strong.wr-page-card-img {
    display: grid;
    place-items: center;
    padding: 0;
  }
  .wr-page-card > strong.wr-page-card-img img {
    display: block;
    width: 22px;
    height: 22px;
  }

  .wr-page-card > strong.wr-page-card-img svg {
    width: 22px;
    height: 22px;
  }

  .wr-actions {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .wr-actions .wr-btn,
  .wr-actions .wr-btn-gold,
  .wr-actions .wr-icon-action,
  .wr-actions .wr-theme-toggle { flex: 0 0 auto; }
  .wr-theme-toggle {
    background: var(--surface-control);
    border-color: var(--border);
  }
  .wr-user-menu {
    flex: 0 0 auto;
    position: sticky;
    right: 0;
    z-index: 5;
    background: var(--bg);
    padding-left: 4px;
  }

  .wr-dash > .wr-topbar #gmMenuBtn,
  .st-shell > .wr-topbar #gmMenuBtn,
  body:has(#gmMenuBtn) .wr-topbar #gmMenuBtn {
    flex: 0 0 auto;
    align-self: center;
    position: sticky;
    left: 0;
    z-index: 6;
    background: var(--bg);
  }

  .wr-user-btn { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: 50%; }
  .wr-user-btn #userBadge { display: none; }
  /* Escape topbar overflow clipping so the account dropdown stays visible. */
  .wr-user-panel {
    position: fixed;
    top: max(66px, calc(env(safe-area-inset-top, 0px) + 56px));
    left: auto;
    right: max(12px, env(safe-area-inset-right, 0px));
    width: min(300px, calc(100vw - 24px));
    max-height: min(70dvh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 10px;
    border-radius: 16px;
    box-shadow: 0 22px 56px rgba(0, 0, 0, 0.34);
  }

  .wr-user-panel {
    --wr-user-control-h: 44px;
  }

  .wr-user-theme {
    margin-top: 6px;
    margin-bottom: 2px;
  }

  .wr-theme-seg {
    height: 38px;
    min-height: 38px;
  }

  .wr-user-setting select {
    font-size: 16px;
  }

  .wr-panel {
    padding: 14px 12px;
    min-height: 360px;
    border-radius: 14px;
  }

  .wr-data-card-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .wr-data-card-actions {
    width: 100%;
    justify-content: space-between;
  }

  .wr-card-font-control input[type="range"] {
    width: min(42vw, 150px);
  }

  .wr-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .wr-kpi-value { font-size: 1.1rem; }

  .chart-grid { grid-template-columns: 1fr; }
  .chart-box { height: 280px; }
  .chart-tall { height: 320px; }
  .chart-medium { height: 260px; }
  .chart-small { height: 200px; }

  .matrix-grid { grid-template-columns: 1fr; }
  .matrix-dim-row { gap: 4px; }
  .matrix-dim-chip { font-size: 0.65rem; padding: 5px 2px; }

  .wr-modal-foot {
    flex-direction: column-reverse;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }

  .wr-modal-foot .wr-btn { width: 100%; min-height: 44px; }
  .wr-upload-import-head { grid-template-columns: 1fr; }
  .wr-upload-file-add { min-height: 108px; }

  .wr-toolbar { flex-direction: column; align-items: flex-start; gap: 10px; }
  .wr-lookback { width: 100%; }
  .wr-lookback input[type="range"] { flex: 1; width: auto; min-width: 0; }

  .chat-form input { font-size: 16px; }
  .dim-tri button { min-height: 44px; }

  .gauge-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
  /* Shared hamburger chrome: drop logo/company/account chip so the page title stays. */
  body:has(#gmMenuBtn) .wr-topbar .wr-logo-link,
  body:has(#gmMenuBtn) .wr-topbar .wr-page-icon,
  body:has(#gmMenuBtn) .wr-topbar .wr-company,
  body:has(#gmMenuBtn) .wr-topbar .wr-subtitle,
  body:has(#gmMenuBtn) .wr-topbar .wr-nav-desktop-home,
  body:has(#gmMenuBtn) .wr-topbar .wr-user-menu {
    display: none !important;
  }

  body:has(#gmMenuBtn) .wr-topbar .wr-title,
  body:has(#gmMenuBtn) .wr-topbar .wr-mars-brand {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    clip: auto !important;
    clip-path: none !important;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: min(52vw, 16rem);
  }
}


@media (max-width: 600px) {
  :root {
    --chat-fab-size: 52px;
  }

  .chat-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: min(80dvh, calc(100dvh - env(safe-area-inset-top, 0px) - var(--kb-inset, 0px)));
    max-height: none;
    border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .chat-fab {
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
  }
}

.wr-login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.wr-login-shell { width: min(520px, 100%); }

.wr-login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.28);
}

.wr-login-brand {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.wr-login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.wr-login-tabs button {
  border: 1px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 800;
}

.wr-login-tabs button.active {
  color: var(--gold-light);
  border-color: rgba(199, 160, 42, 0.5);
  background: rgba(199, 160, 42, 0.14);
}

.wr-login-form,
.wr-admin-form,
.wr-form-grid {
  display: grid;
  gap: 12px;
}

.wr-login-form label,
.wr-admin-form label,
.wr-form-grid label {
  display: grid;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 800;
  font-size: 0.86rem;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 42px;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(199, 160, 42, 0.25);
  border-color: rgba(199, 160, 42, 0.6);
}

.wr-inline-fields {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.wr-check {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
}

.wr-check input { min-height: auto; }

.wr-error {
  margin-top: 12px;
  color: var(--accent-red);
  font-weight: 800;
}

.wr-status {
  min-height: 22px;
  margin: -4px 0 12px;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.wr-status[data-kind="success"] { color: var(--accent-green); }
.wr-status[data-kind="error"] { color: var(--accent-red); }
.wr-status[data-kind="pending"] { color: var(--gold-light); }

.wr-admin-grid {
  display: grid;
  gap: 18px;
}

.wr-maintenance-log {
  margin: 12px 0 0;
  max-height: 240px;
  overflow: auto;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-all;
}

.wr-admin-form {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  margin: 14px 0;
}

.wr-admin-label {
  grid-column: 1 / -1;
}

.wr-branding-logo-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wr-branding-logo-row .wr-logo {
  width: 72px;
  height: 72px;
}

.wr-branding-logo-actions {
  display: grid;
  gap: 10px;
}

.wr-inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Button rows must span the whole admin form grid, otherwise they wrap into a
   single narrow column. */
.wr-admin-form > .wr-inline-actions {
  grid-column: 1 / -1;
}

/* MCP 「自建系统」放行清单：表格行内展开的勾选面板 */
.wr-table tr.mcp-apps-row td {
  white-space: normal;
  padding: 0;
  background: var(--surface-subtle, var(--bg-card));
}

.mcp-apps-panel {
  padding: 12px 10px 14px;
  border-left: 3px solid var(--gold);
}

.mcp-apps-hint {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.6;
}

.mcp-apps-stale {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--accent-red);
  border-radius: 6px;
  background: rgba(220, 80, 80, 0.08);
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.6;
}

.mcp-apps-fresh {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  background: rgba(199, 160, 42, 0.12);
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.6;
}

.mcp-apps-item.is-new {
  border-color: var(--gold);
  background: rgba(199, 160, 42, 0.08);
}

.mcp-apps-new {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--gold);
  color: #1a1408;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: middle;
}

.mcp-apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px 16px;
  margin-bottom: 12px;
}

.mcp-apps-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 8px;
  border: 1px solid var(--border-soft, var(--border));
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.mcp-apps-item:hover {
  border-color: var(--gold);
  background: var(--bg-card-hover, var(--bg-card));
}

.mcp-apps-item input {
  margin-top: 3px;
  flex: none;
  accent-color: var(--gold);
}

.mcp-apps-item code {
  display: block;
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 700;
}

.mcp-apps-item em {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-style: normal;
  line-height: 1.45;
}

@media (max-width: 768px) {
  .mcp-apps-grid {
    grid-template-columns: 1fr;
  }
}

.wr-feature-fieldset {
  grid-column: 1 / -1;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-secondary);
}

.wr-feature-fieldset legend {
  padding: 0 6px;
  font-weight: 800;
}

.wr-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px 14px;
}

.wr-feature-grid-compact {
  min-width: 310px;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
}

.wr-feature-grid-pages { min-width: 150px; grid-template-columns: 1fr; }

@media (max-width: 640px) {
  .wr-feature-grid,
  .wr-feature-grid-compact {
    min-width: 0;
    grid-template-columns: 1fr;
  }
}

.wr-price-add {
  align-items: center;
  justify-content: center;
  min-height: 132px;
  cursor: pointer;
  color: var(--text-secondary);
}

.wr-price-add-plus {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px dashed rgba(199, 160, 42, 0.6);
  color: var(--gold-light);
  font-size: 1.8rem;
  margin: 0 auto 8px;
}

.wr-price-remove {
  border: 1px solid var(--border);
  background: var(--bg-card-hover);
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 999px;
  cursor: pointer;
}

.wr-modal-wide { width: min(1120px, calc(100vw - 28px)); }

.wr-modal-resizable {
  min-width: min(760px, calc(100vw - 28px));
  min-height: 420px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  resize: both;
  overflow: hidden;
}

.wr-modal-resizable::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 16px;
  height: 16px;
  pointer-events: none;
  opacity: 0.72;
  background:
    linear-gradient(135deg, transparent 0 50%, rgba(199, 160, 42, 0.58) 50% 58%, transparent 58%),
    linear-gradient(135deg, transparent 0 68%, rgba(199, 160, 42, 0.42) 68% 76%, transparent 76%);
}

.wr-modal-extra-wide {
  width: min(1280px, calc(100vw - 28px));
  min-width: min(720px, calc(100vw - 28px));
  min-height: 360px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  overflow: hidden;
  resize: both;
}

.wr-modal-extra-wide::after {
  content: "";
  position: absolute;
  right: 7px;
  bottom: 7px;
  width: 16px;
  height: 16px;
  pointer-events: none;
  opacity: 0.72;
  background:
    linear-gradient(135deg, transparent 0 50%, rgba(199, 160, 42, 0.58) 50% 58%, transparent 58%),
    linear-gradient(135deg, transparent 0 68%, rgba(199, 160, 42, 0.42) 68% 76%, transparent 76%);
}

.wr-data-modal-body {
  overflow: auto;
}

.wr-data-modal-body > .wr-card-font-control {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: -4px 0 10px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
}

.wr-data-modal-body .wr-data-card,
.wr-data-modal-body .wr-table-wrap {
  margin: 0;
}

.wr-data-modal-body .wr-table-wrap {
  min-height: 240px;
}

.wr-data-modal-body table.wr-table {
  min-width: max-content;
}

.wr-upload-sheet-wrap {
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-inset);
  max-height: min(52vh, 520px);
}

.wr-upload-group-summary {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.wr-upload-group {
  margin-top: 14px;
  padding: 10px;
  border: 1px solid rgba(199, 160, 42, 0.24);
  border-radius: 10px;
  background: var(--surface-inset);
}

.wr-upload-account-tabs {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.wr-upload-account-tabs button {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-control);
  color: var(--text-secondary);
  padding: 8px 12px;
  cursor: pointer;
  font: inherit;
  white-space: nowrap;
}

.wr-upload-account-tabs button span {
  margin-left: 6px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.wr-upload-account-tabs button.active {
  border-color: rgba(199, 160, 42, 0.62);
  background: rgba(199, 160, 42, 0.16);
  color: var(--text);
}

.wr-upload-account-tabs button.has-error {
  border-color: rgba(239, 68, 68, 0.52);
}

.wr-upload-group.has-error {
  border-color: rgba(239, 68, 68, 0.42);
}

.wr-upload-error-card {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(239, 68, 68, 0.36);
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.08);
}

.wr-upload-error-card strong {
  color: #fecaca;
}

:is(:root, body)[data-theme="light"] .wr-upload-error-card strong {
  color: #b91c1c;
}

.wr-upload-error-card p {
  margin: 6px 0 12px;
  color: var(--text-muted);
  white-space: pre-wrap;
}

.wr-upload-group-head {
  display: grid;
  grid-template-columns: minmax(160px, 1.3fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(120px, 1fr);
  gap: 10px;
  align-items: end;
}

.wr-upload-group-head label {
  display: grid;
  gap: 4px;
  color: var(--text-muted);
  font-size: 0.76rem;
}

.wr-upload-group-head input {
  width: 100%;
  height: 30px;
}

.wr-upload-sheet-table {
  min-width: 1540px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.wr-upload-sheet-table .col-product { width: 110px; }
.wr-upload-sheet-table .col-contract { width: 110px; }
.wr-upload-sheet-table .col-direction { width: 78px; }
.wr-upload-sheet-table .col-lots { width: 88px; }
.wr-upload-sheet-table .col-price { width: 116px; }
.wr-upload-sheet-table .col-multiplier { width: 86px; }
.wr-upload-sheet-table .col-money { width: 132px; }
.wr-upload-sheet-table .col-margin { width: 128px; }
.wr-upload-sheet-table .col-ratio { width: 96px; }
.wr-upload-sheet-table .col-action { width: 42px; }

.wr-upload-sheet-table th,
.wr-upload-sheet-table td {
  border: 0;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 0;
  height: 32px;
  background: var(--sheet-cell-bg);
}

.wr-upload-sheet-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 30px;
  padding: 0 7px;
  background: var(--sheet-head-bg);
  color: var(--text-secondary);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.wr-upload-sheet-table tr:hover td {
  background: rgba(199, 160, 42, 0.08);
}

.wr-upload-sheet-table td.num input {
  text-align: right;
}

.wr-upload-sheet-table input,
.wr-upload-sheet-table select {
  min-width: 0;
  width: 100%;
  height: 31px;
  border: 0;
  border-radius: 0;
  padding: 0 7px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  font: inherit;
  font-variant-numeric: tabular-nums;
}

.wr-upload-sheet-table select {
  cursor: pointer;
}

.wr-upload-sheet-table input:focus,
.wr-upload-sheet-table select:focus {
  outline: 2px solid rgba(199, 160, 42, 0.75);
  outline-offset: -2px;
  background: var(--sheet-focus-bg);
}

.wr-upload-sheet-table .wr-icon-btn {
  display: block;
  width: 100%;
  height: 31px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-muted);
}

.wr-upload-sheet-table .wr-icon-btn:hover {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
}

:is(:root, body)[data-theme="light"] .wr-upload-sheet-table .wr-icon-btn:hover {
  color: #b91c1c;
}

.wr-account-detail-list {
  display: grid;
  gap: 14px;
}

.wr-account-detail-card {
  margin: 0;
}

.wr-edit-table input,
.wr-edit-table select {
  min-width: 92px;
  width: 100%;
}

.wr-upload-sheet-table input,
.wr-upload-sheet-table select {
  min-width: 0;
}

.wr-calendar-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.wr-calendar-day {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  border-radius: 14px;
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
}

.wr-calendar-day span {
  color: var(--text-muted);
  font-size: 0.82rem;
}

:is(:root, body)[data-theme="light"] .wr-logo {
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

:is(:root, body)[data-theme="light"] .wr-btn {
  background: #fff9e6;
  color: #8a6b12;
}

:is(:root, body)[data-theme="light"] .wr-btn-ghost {
  background: #ffffff;
  color: #334155;
}

:is(:root, body)[data-theme="light"] .wr-modal:not(:has(.wr-modal-backdrop)) {
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(3px);
}

:is(:root, body)[data-theme="light"] .wr-price-card,
:is(:root, body)[data-theme="light"] .wr-panel,
:is(:root, body)[data-theme="light"] .wr-modal-sheet,
:is(:root, body)[data-theme="light"] .chat-panel,
:is(:root, body)[data-theme="light"] .wr-login-card {
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

:is(:root, body)[data-theme="light"] .wr-page-card,
:is(:root, body)[data-theme="light"] .wr-price-card {
  background: var(--surface-raised);
}

:is(:root, body)[data-theme="light"] .wr-page-card:hover {
  background: linear-gradient(145deg, rgba(199, 160, 42, 0.14), var(--surface-subtle));
}

:is(:root, body)[data-theme="light"] .wr-price-card.gain {
  background: linear-gradient(145deg, rgba(229,62,62,0.10), rgba(229,62,62,0));
}

:is(:root, body)[data-theme="light"] .wr-price-card.loss {
  background: linear-gradient(145deg, rgba(56,161,105,0.10), rgba(56,161,105,0));
}
