:root {
  color-scheme: dark;
  --bg: #060b14;
  --panel: rgba(13, 23, 39, .86);
  --panel-strong: #101c2e;
  --line: rgba(147, 172, 208, .16);
  --text: #f3f7ff;
  --muted: #8fa1bd;
  --gold: #f5bd42;
  --gold-2: #ffe59d;
  --blue: #3c82ff;
  --red: #ff4f61;
  --green: #2fd698;
  --shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(39, 101, 210, .18), transparent 30%),
    radial-gradient(circle at 90% 0%, rgba(245, 189, 66, .11), transparent 26%),
    linear-gradient(180deg, #07101d 0%, #050911 100%);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
.ambient { position: fixed; z-index: -1; filter: blur(110px); border-radius: 50%; opacity: .5; pointer-events: none; }
.ambient-one { width: 330px; height: 330px; left: -180px; top: 260px; background: #245cba; }
.ambient-two { width: 280px; height: 280px; right: -150px; top: 500px; background: #6f5215; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: 66px;
  padding: 0 4vw;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  background: rgba(5, 10, 18, .8);
  backdrop-filter: blur(18px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; letter-spacing: .08em; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px; color: #191203; background: linear-gradient(145deg, var(--gold-2), var(--gold)); box-shadow: 0 7px 20px rgba(245, 189, 66, .25); }
.topnav { display: flex; align-items: center; gap: 8px; }
.topnav a { padding: 9px 14px; color: #aebbd0; border-radius: 10px; font-size: 14px; transition: .18s ease; }
.topnav a:hover, .topnav a.active { color: #fff; background: rgba(255, 255, 255, .07); }
.user-menu { position: relative; justify-self: end; }
.user-chip { max-width: 260px; min-height: 38px; padding: 0 10px; display: flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; color: #aebbd0; background: transparent; cursor: pointer; font-size: 13px; white-space: nowrap; transition: .18s ease; }
.user-chip:hover, .user-chip[aria-expanded="true"] { color: #fff; border-color: var(--line); background: rgba(255, 255, 255, .055); }
.user-chip #userName { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.user-caret { width: 0; height: 0; margin-left: 2px; border-right: 4px solid transparent; border-left: 4px solid transparent; border-top: 5px solid currentColor; transition: transform .18s ease; }
.user-chip[aria-expanded="true"] .user-caret { transform: rotate(180deg); }
.user-dropdown { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; min-width: 132px; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: #101a2a; box-shadow: 0 16px 38px rgba(0,0,0,.38); }
.user-dropdown button { width: 100%; min-height: 38px; padding: 0 12px; border: 0; border-radius: 8px; color: #ff9aa5; background: transparent; cursor: pointer; text-align: left; font-weight: 700; }
.user-dropdown button:hover { background: rgba(255,79,97,.11); }
.status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(47, 214, 152, .12); }

.shell { width: min(1460px, 92vw); margin: 0 auto; padding: 48px 0 80px; }
.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; margin-bottom: 28px; }
.eyebrow, .panel-kicker { margin: 0 0 8px; color: var(--gold); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 0; font-size: clamp(34px, 4.3vw, 62px); line-height: 1.05; letter-spacing: -.04em; }
.hero-copy { max-width: 720px; margin: 15px 0 0; color: #a7b5c9; line-height: 1.75; }
.hero-actions, .control-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button { min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: 11px; color: #fff; cursor: pointer; font-weight: 750; transition: transform .16s ease, border-color .16s ease, filter .16s ease; }
.button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.button:disabled { opacity: .45; cursor: wait; transform: none; }
.button.primary { color: #1c1404; background: linear-gradient(135deg, #ffe29a, #f2b52f); box-shadow: 0 12px 28px rgba(245, 189, 66, .19); }
.button.secondary { border-color: rgba(108, 151, 231, .35); background: rgba(44, 92, 169, .22); }
.button.danger { border-color: rgba(255, 79, 97, .4); background: rgba(187, 39, 57, .27); }
.button.ghost { border-color: var(--line); background: rgba(255, 255, 255, .035); color: #c2cde0; }
.button.compact { min-height: 36px; padding: 0 13px; font-size: 13px; }

.shadow-notice { margin-bottom: 22px; padding: 15px 18px; display: flex; align-items: center; gap: 14px; border: 1px solid rgba(245, 189, 66, .24); border-radius: 15px; background: linear-gradient(100deg, rgba(245, 189, 66, .10), rgba(245, 189, 66, .025)); }
.shadow-notice .shield { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; color: #261b04; background: var(--gold); font-weight: 900; }
.shadow-notice p { margin: 4px 0 0; color: #a7b5c9; font-size: 13px; }
.mode-pill { margin-left: auto; padding: 6px 10px; border: 1px solid rgba(245, 189, 66, .28); border-radius: 999px; color: var(--gold-2); background: rgba(245, 189, 66, .08); font-size: 11px; font-weight: 900; letter-spacing: .12em; }

.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.metric-card, .panel { border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.metric-card { min-height: 130px; padding: 21px; border-radius: 16px; display: flex; flex-direction: column; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-card strong { margin-top: auto; font-size: 24px; letter-spacing: -.02em; }
.metric-card small { margin-top: 5px; color: var(--muted); }
#floatingPnl { margin-top: 8px; font-size: 20px; font-weight: 750; letter-spacing: .01em; }
.profit { color: var(--red) !important; }
.loss { color: var(--green) !important; }
.position-profit { color: var(--green) !important; }
.position-loss { color: var(--red) !important; }

.main-grid, .secondary-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.main-grid { grid-template-columns: minmax(0, 1.35fr) minmax(380px, .65fr); }
.secondary-grid { grid-template-columns: 1.2fr .8fr; }
.panel { padding: 24px; border-radius: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.agent-state { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: #c2cde0; background: rgba(255,255,255,.04); font-size: 12px; font-weight: 800; white-space: nowrap; }
.agent-state::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px rgba(255,255,255,.06); }
.agent-state.running { color: #43d9a3; border-color: rgba(67,217,163,.32); background: rgba(67,217,163,.09); }
.agent-state.paused { color: #f5bd42; border-color: rgba(245,189,66,.32); background: rgba(245,189,66,.09); }
.agent-state.emergency { color: #ff6c7b; border-color: rgba(255,79,97,.38); background: rgba(187,39,57,.18); }
.agent-state.off { color: #8d9bb1; }
.quote { text-align: right; }
.quote span, .quote small { display: block; color: var(--muted); font-size: 11px; }
.quote strong { display: block; margin: 3px 0; font-size: 26px; }

.timeframe-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.tf-card { padding: 15px; min-height: 116px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, .025); }
.tf-card > span { color: var(--muted); font-size: 11px; font-weight: 800; }
.tf-card strong { display: block; margin: 18px 0 7px; font-size: 15px; }
.tf-card small { color: var(--muted); font-size: 11px; }
.tf-card.long { border-color: rgba(255, 79, 97, .25); background: rgba(255, 79, 97, .055); }
.tf-card.long strong { color: #ff8b98; }
.tf-card.short { border-color: rgba(47, 214, 152, .25); background: rgba(47, 214, 152, .055); }
.tf-card.short strong { color: #62e6b6; }
.market-foot { display: flex; justify-content: space-between; gap: 20px; margin-top: 17px; color: var(--muted); font-size: 12px; }
.market-foot b { color: #cbd6e7; font-weight: 650; }

.decision-badge, .tiny-pill { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: #b7c4d8; background: rgba(255, 255, 255, .04); font-size: 11px; font-weight: 850; }
.decision-badge.long { color: #ff9aa5; border-color: rgba(255,79,97,.3); background: rgba(255,79,97,.09); }
.decision-badge.short { color: #6ce8bb; border-color: rgba(47,214,152,.3); background: rgba(47,214,152,.09); }
.confidence-wrap { padding: 16px; border-radius: 14px; background: rgba(255, 255, 255, .03); }
.confidence-wrap > div:first-child { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12px; }
.confidence-wrap strong { color: #fff; font-size: 23px; }
.confidence-track { height: 7px; margin-top: 10px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .07); }
.confidence-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--gold)); transition: width .4s ease; }
.decision-list { margin: 14px 0; }
.decision-list > div { display: grid; grid-template-columns: 118px 1fr; gap: 12px; padding: 11px 2px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.decision-list dt { color: var(--muted); font-size: 12px; }
.decision-list dd { margin: 0; text-align: right; color: #dbe5f4; font-size: 13px; }
.decision-summary { min-height: 52px; margin: 14px 0; color: #aebbd0; line-height: 1.65; font-size: 13px; }
.reason-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.reason-tags span { padding: 5px 8px; border-radius: 7px; color: #9fb4d3; background: rgba(57, 101, 170, .14); font-size: 10px; }

.setting-switch { margin: 20px 0; padding: 15px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255, 255, 255, .025); }
.setting-switch strong, .setting-switch small { display: block; }
.setting-switch small { margin-top: 4px; color: var(--muted); }
.switch { position: relative; width: 48px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; }
.switch span { display: block; width: 100%; height: 100%; border-radius: 999px; background: #263449; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 4px; left: 4px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::after { transform: translateX(22px); }
.settings-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-bottom: 15px; }
.settings-grid label { color: var(--muted); font-size: 11px; }
.settings-grid input, .license-form input, .license-form select, .onboarding-form input, .onboarding-form select, .model-key-row select { width: 100%; height: 38px; margin-top: 7px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; color: #fff; background: rgba(4, 10, 19, .65); outline: none; }
.settings-grid input:focus, .license-form input:focus, .license-form select:focus, .onboarding-form input:focus, .onboarding-form select:focus, .model-key-row select:focus { border-color: rgba(60, 130, 255, .65); }

.bridge-panel > p { color: var(--muted); font-size: 13px; line-height: 1.7; }
.readiness-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.readiness-grid > div { padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: rgba(255,255,255,.025); }
.readiness-grid span, .readiness-grid b { display: block; }
.readiness-grid span { color: var(--muted); font-size: 10px; }
.readiness-grid b { margin-top: 5px; color: #8798b2; font-size: 12px; }
.readiness-grid b.ready { color: var(--green); }
.onboarding-block { margin-top: 13px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.02); }
.onboarding-block > strong { display: block; margin-bottom: 10px; font-size: 13px; }
.onboarding-form { display: grid; grid-template-columns: .65fr 1.35fr; gap: 9px; }
.onboarding-form label { color: var(--muted); font-size: 10px; }
.onboarding-actions { align-items: center; margin-top: 10px; }
.request-status { color: var(--muted); font-size: 11px; }
.request-status.pending { color: var(--gold); }
.request-status.rejected { color: var(--red); }
.onboarding-detail { display: block; margin-top: 8px; color: var(--muted); line-height: 1.55; }
.model-key-row { display: grid; grid-template-columns: 1fr auto; gap: 9px; align-items: end; }
.model-key-row select { margin-top: 0; }
.bridge-meta { margin: 19px 0; display: grid; gap: 10px; color: var(--muted); font-size: 12px; }
.bridge-meta b { color: #dce5f3; }
.license-code-row { display: flex; align-items: center; gap: 7px; }
.license-copy-button { min-height: 24px; padding: 0 9px; border: 1px solid rgba(245, 189, 66, .32); border-radius: 7px; color: var(--gold-2); background: rgba(245, 189, 66, .09); cursor: pointer; font-size: 11px; font-weight: 750; }
.license-copy-button:hover { filter: brightness(1.14); }
.license-copy-button:disabled { opacity: .45; cursor: wait; }
.token-box { margin-top: 14px; padding: 13px; border: 1px solid rgba(245, 189, 66, .22); border-radius: 12px; background: rgba(245, 189, 66, .06); }
.token-box > span { display: block; color: var(--gold); font-size: 10px; font-weight: 800; }
.token-box code { display: block; margin: 9px 0; color: #fff0c6; overflow-wrap: anywhere; font-size: 12px; }
.hidden { display: none !important; }

.admin-panel { margin-bottom: 14px; }
.shadow-simulation-panel { margin-bottom: 14px; }
.shadow-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.shadow-summary-grid > div { padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); }
.shadow-summary-grid span, .shadow-summary-grid strong { display: block; }
.shadow-summary-grid span { color: var(--muted); font-size: 10px; }
.shadow-summary-grid strong { margin-top: 6px; color: #e3ebf7; font-size: 16px; }
.shadow-summary-grid strong.profit { color: var(--red); }
.shadow-summary-grid strong.loss { color: var(--green); }
.shadow-execution { margin-bottom: 12px; padding: 11px 13px; border-radius: 10px; color: #9eb0c9; background: rgba(57,101,170,.10); font-size: 12px; }
.shadow-trade-table { min-width: 900px; }
.admin-subtitle { margin: 22px 0 10px; color: #d9e3f2; font-size: 14px; }
.license-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 11px; margin-bottom: 15px; }
.license-form label { color: var(--muted); font-size: 11px; }
.license-form select { appearance: none; }
.admin-hint { align-self: center; color: var(--muted); line-height: 1.5; }
.license-table-wrap { margin-top: 18px; }
.license-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.license-actions button { min-height: 30px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; color: #cbd7e8; background: rgba(255,255,255,.045); cursor: pointer; font-size: 10px; }
.license-actions button.danger { color: #ff9aa5; border-color: rgba(255,79,97,.28); }

.history-panel { padding-bottom: 12px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th, td { padding: 13px 11px; border-bottom: 1px solid rgba(255, 255, 255, .055); text-align: left; font-size: 12px; }
th { color: #768aa8; font-weight: 650; }
td { color: #c1cde0; }
.empty-row { height: 90px; text-align: center; color: var(--muted); }
.table-pill { padding: 4px 7px; border-radius: 6px; background: rgba(255, 255, 255, .05); font-size: 10px; font-weight: 800; }

.toast { position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: min(420px, calc(100vw - 36px)); padding: 13px 16px; border: 1px solid var(--line); border-radius: 12px; color: #fff; background: #17243a; box-shadow: 0 18px 50px rgba(0,0,0,.35); opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-color: rgba(255,79,97,.4); background: #3a1820; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .shadow-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-grid, .secondary-grid { grid-template-columns: 1fr; }
  .timeframe-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .topbar { height: auto; min-height: 62px; grid-template-columns: 1fr auto; padding: 12px 4vw; }
  .topnav { order: 3; grid-column: 1 / -1; margin-top: 8px; overflow-x: auto; }
  .user-chip { max-width: 160px; }
  .user-chip #userName { max-width: 92px; }
  .shell { width: min(94vw, 680px); padding-top: 32px; }
  .metric-grid { grid-template-columns: 1fr; }
  .hero { align-items: flex-start; flex-direction: column; }
  .timeframe-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
  .license-form { grid-template-columns: repeat(2, 1fr); }
  .onboarding-form { grid-template-columns: 1fr; }
  .shadow-notice { align-items: flex-start; }
  .mode-pill { display: none; }
}
@media (max-width: 470px) {
  .brand { font-size: 13px; }
  .metric-grid, .settings-grid, .license-form, .readiness-grid { grid-template-columns: 1fr; }
  .shadow-summary-grid { grid-template-columns: 1fr; }
  .model-key-row { grid-template-columns: 1fr; }
  .hero-actions, .hero-actions .button { width: 100%; }
  .panel, .metric-card { padding: 18px; }
  .market-foot { flex-direction: column; gap: 6px; }
}
