:root {
  --bg: #0d1012;
  --panel: #161a1d;
  --line: #343b40;
  --text: #f3f1eb;
  --muted: #b7bdc0;
  --accent: #e4a93b;
  --danger: #ef756d;
  --ok: #78c29d;
  --radius: 14px;
  --font-body: 17px;
  --font-small: 14px;
  --tap: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: linear-gradient(160deg, #171b1e 0, #0d1012 35%);
  font-size: var(--font-body);
  line-height: 1.65;
}
button, input, select { font: inherit; }

.topbar {
  height: 68px;
  max-width: 920px;
  margin: auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--text); font-size: 18px; font-weight: 760; letter-spacing: -.02em; text-decoration: none; }
.research-tag {
  color: var(--accent);
  border: 1px solid #665028;
  border-radius: 999px;
  padding: 8px 10px;
  font: 700 12px/1 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: .08em;
}
.shell { width: min(100%, 920px); margin: auto; padding: 28px 18px calc(104px + var(--safe-bottom)); }
.shell--auth { min-height: calc(100dvh - 68px); display: grid; place-items: center; padding-bottom: 28px; }

.page-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: end; margin-bottom: 28px; }
.page-head h1, .login-panel h1, .error-panel h1 {
  margin: 7px 0 0;
  font-size: clamp(32px, 8vw, 54px);
  line-height: 1.08;
  letter-spacing: -.04em;
}
.date-line, .kicker {
  margin: 0;
  color: var(--muted);
  font: 650 14px/1.35 ui-monospace, SFMono-Regular, monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.status { min-width: 180px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); display: grid; gap: 5px; }
.status strong { color: var(--accent); font: 750 14px/1.2 ui-monospace, SFMono-Regular, monospace; }
.status span { color: var(--muted); font-size: var(--font-small); line-height: 1.45; }
.status--system_error { border-color: #71403d; }
.status--system_error strong, .status--stale strong { color: var(--danger); }
.status--normal strong { color: var(--ok); }

.metric-strip { display: grid; grid-template-columns: repeat(3, 1fr); border-block: 1px solid var(--line); margin-bottom: 36px; }
.metric-strip div { padding: 20px 14px; }
.metric-strip div + div { border-left: 1px solid var(--line); }
.metric-strip span { display: block; color: var(--muted); font-size: var(--font-small); }
.metric-strip strong { display: block; margin-top: 5px; font-size: clamp(24px, 7vw, 36px); letter-spacing: -.035em; }

.section-block { margin-top: 38px; }
.section-block h2 { display: flex; justify-content: space-between; margin: 0 0 16px; font-size: 21px; line-height: 1.3; }
.section-block h2 span { color: var(--muted); font: 500 var(--font-small) ui-monospace, monospace; }
.boundary { margin: 0; padding: 18px; border-left: 4px solid var(--accent); background: #191a17; color: #e3ddd1; }
.muted, .empty { color: var(--muted); }
.report-text {
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: #dde0e2;
  font: 14px/1.8 ui-monospace, SFMono-Regular, monospace;
}

.advice-row { padding: 22px 0; border-top: 1px solid var(--line); }
.advice-row > div:first-child { display: flex; align-items: center; justify-content: space-between; }
.advice-row strong { font: 760 22px/1.25 ui-monospace, SFMono-Regular, monospace; }
.state-label { color: var(--accent); font-size: var(--font-small); font-weight: 700; }
.advice-row p { margin: 10px 0; color: #dfe1e2; }
.advice-row dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0 0; }
.advice-row dl div { padding-right: 8px; }
.advice-row dt { color: var(--muted); font-size: var(--font-small); }
.advice-row dd { margin: 4px 0; font-size: 16px; font-weight: 700; }
.advice-row .risk-copy { color: var(--muted); font-size: var(--font-small); line-height: 1.65; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table{width:100%;border-collapse:collapse;min-width:0}
th, td { text-align: left; padding: 15px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: var(--font-small); font-weight: 650; }
td { font-size: 16px; }
.history-list { border-top: 1px solid var(--line); }
.history-list a { min-height: 64px; display: flex; align-items: center; justify-content: space-between; color: var(--text); text-decoration: none; border-bottom: 1px solid var(--line); }
.history-list a span:last-child { color: var(--accent); font-size: var(--font-small); }

.login-panel { width: min(100%, 680px); display: grid; grid-template-columns: 1fr 1fr; gap: 44px; align-items: start; }
.form-stack { display: grid; gap: 18px; }
.form-stack label, .trade-form label { display: grid; gap: 8px; color: var(--muted); font-size: var(--font-small); }
.form-stack input, .trade-form input, .trade-form select {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid #515a60;
  border-radius: 10px;
  background: #111416;
  color: var(--text);
  font-size: 17px;
  padding: 11px 13px;
  outline: none;
}
.form-stack input:focus, .trade-form input:focus, .trade-form select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #e4a93b24; }
.form-stack button, .button-link, .inline-action button, .trade-form button {
  min-height: var(--tap);
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #16120a;
  font-weight: 800;
  padding: 0 20px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.form-stack button:active, .button-link:active, .inline-action button:active, .trade-form button:active { transform: translateY(1px); }
.form-error { margin: 0; color: #ff9a93; }
.error-panel { max-width: 520px; }

.action-panel { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.action-panel h2, .action-panel p { margin: 0; }
.trade-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 20px; }
.trade-form button { grid-column: 1 / -1; }
.form-success { padding: 12px 14px; border-left: 4px solid var(--ok); background: #13201a; color: #c4e4d2; }

.bottom-nav {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 920px);
  height: calc(76px + var(--safe-bottom));
  padding: 0 8px var(--safe-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: #111517f2;
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.bottom-nav a { min-height: var(--tap); display: grid; place-items: center; color: var(--muted); text-decoration: none; font-size: 15px; }
.bottom-nav a[aria-current=page] { color: var(--accent); font-weight: 750; }

@media (max-width: 640px) {
  .topbar, .shell { padding-inline: 16px; }
  .shell { padding-top: 24px; }
  .page-head { grid-template-columns: 1fr; gap: 16px; }
  .status { min-width: 0; }
  .metric-strip div { padding: 18px 8px; }
  .metric-strip strong { font-size: 26px; }
  .advice-row dl { grid-template-columns: 1fr 1fr; }
  .login-panel { grid-template-columns: 1fr; gap: 30px; }
  .action-panel { align-items: stretch; flex-direction: column; }
  .inline-action button { width: 100%; }
  .trade-form { grid-template-columns: 1fr; }
  th, td { padding-inline: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
