:root {
  --nav: #17221e;
  --ink: #17211d;
  --muted: #6d7b74;
  --line: #dce5df;
  --line-soft: #eaf0ec;
  --canvas: #f4f7f5;
  --card: #fff;
  --green: #176b4c;
  --green-dark: #0e553b;
  --green-soft: #e4f2eb;
  --red: #a33b38;
  --red-soft: #f9e9e7;
  --amber: #a46a0d;
  --amber-soft: #fff7e8;
  --shadow: 0 12px 36px rgba(27, 49, 39, .07);
  --sidebar: 246px;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input, select { font: inherit; }
button { border: 0; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar); padding: 28px 18px 20px; color: #eef6f1; background: radial-gradient(circle at 13% 0, rgba(77, 145, 110, .22), transparent 34%), var(--nav); display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark { width: 40px; height: 40px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .19); border-radius: 11px; color: #fff; background: linear-gradient(145deg, #297a5a, #164f3a); font-weight: 800; letter-spacing: .5px; }
.brand h1 { margin: 0; font-size: 17px; line-height: 1.25; letter-spacing: .2px; }
.brand p { margin: 3px 0 0; color: #91a69b; font-size: 11px; }
nav { display: grid; gap: 6px; }
.instance-switcher { margin-top: 18px; padding-top: 15px; border-top: 1px solid rgba(255,255,255,.12); }
.instance-switcher-head { display: flex; align-items: center; justify-content: space-between; padding: 0 8px 8px; color: #9fb4a9; }
.instance-switcher-head small { font-size: 9px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; }
.instance-switcher-head button { width: 26px; min-height: 26px; height: 26px; padding: 0; border: 1px solid rgba(255,255,255,.18); border-radius: 6px; color: #fff; background: rgba(255,255,255,.07); }
#instance-list { display: grid; gap: 5px; max-height: 235px; overflow: auto; }
.instance-loading { margin: 6px 8px; color: #8fa49a; font-size: 10px; }
.instance-item { width: 100%; min-height: 48px; padding: 9px 10px; display: grid; grid-template-columns: 8px minmax(0,1fr); gap: 2px 8px; border: 1px solid transparent; border-radius: 7px; color: #c6d3cc; background: transparent; text-align: left; }
.instance-item:hover { background: rgba(255,255,255,.055); }
.instance-item.active { border-color: rgba(104,207,158,.28); background: rgba(59,143,105,.22); color: #fff; }
.instance-item i { grid-row: 1 / 3; align-self: center; width: 7px; height: 7px; border-radius: 50%; background: #77877f; }
.instance-item.running i { background: #47d492; box-shadow: 0 0 0 3px rgba(71,212,146,.12); }
.instance-item strong { overflow: hidden; text-overflow: ellipsis; font-size: 10px; white-space: nowrap; }
.instance-item small { overflow: hidden; color: #8fa49a; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.instance-row { position: relative; }
.instance-row .instance-item { padding-right: 48px; }
.instance-delete { position: absolute; z-index: 2; right: 7px; top: 50%; width: auto; min-height: 24px; padding: 3px 6px; transform: translateY(-50%); border: 1px solid rgba(244,151,145,.32); border-radius: 5px; color: #f1aaa5; background: rgba(127,37,32,.16); font-size: 8px; }
.instance-delete:hover:not(:disabled) { color: #fff; background: rgba(174,55,48,.55); }
.instance-delete:disabled { opacity: .35; cursor: not-allowed; }
.broker-switcher { margin-top: 14px; padding-top: 13px; border-top: 1px solid rgba(255,255,255,.12); }
.broker-card { width: 100%; min-height: 52px; padding: 9px 10px; display: grid; grid-template-columns: 8px minmax(0,1fr) auto; align-items: center; gap: 8px; border: 1px solid rgba(255,255,255,.1); border-radius: 7px; color: #d5e0da; background: rgba(255,255,255,.035); text-align: left; }
.broker-card:hover { border-color: rgba(104,207,158,.3); background: rgba(255,255,255,.06); }
.broker-card > i { width: 7px; height: 7px; border-radius: 50%; background: #77877f; }
.broker-card.enabled > i { background: #47d492; box-shadow: 0 0 0 3px rgba(71,212,146,.12); }
.broker-card span { min-width: 0; }
.broker-card strong, .broker-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.broker-card strong { color: #fff; font-size: 10px; }
.broker-card small { margin-top: 2px; color: #8fa49a; font-size: 8px; }
.broker-card b { color: #7ed0aa; font-size: 9px; }
.nav-item { width: 100%; padding: 12px 13px; display: flex; align-items: center; gap: 11px; border-radius: 8px; color: #a9bbb1; background: transparent; text-align: left; cursor: pointer; transition: .18s ease; }
.nav-item span { width: 20px; color: #7f988b; font-size: 17px; text-align: center; }
.nav-item:hover { color: #fff; background: rgba(255, 255, 255, .055); }
.nav-item.active { color: #fff; background: #294139; box-shadow: inset 3px 0 #56b087; }
.nav-item.active span { color: #7ed0aa; }
.side-card { margin-top: auto; padding: 14px; border: 1px solid rgba(255, 255, 255, .09); border-radius: 9px; background: rgba(255, 255, 255, .035); }
.side-card small { display: block; color: #7f988b; font-size: 10px; letter-spacing: 1.3px; }
.side-card strong { display: block; margin-top: 6px; font-size: 12px; }
.side-card p { margin: 4px 0 0; color: #91a69b; font-size: 11px; }
.connection { display: flex; align-items: center; gap: 8px; padding: 17px 8px 0; color: #91a69b; font-size: 11px; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #76857e; }
.connection.online i { background: #43be82; box-shadow: 0 0 0 4px rgba(67, 190, 130, .12); }
.connection.offline i { background: #d46864; }

.feishao-user-card { margin: 18px 0 12px; padding: 14px; border: 1px solid rgba(255, 255, 255, .09); border-radius: 14px; background: rgba(255, 255, 255, .04); display: grid; gap: 7px; }
.feishao-user-card small { color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.feishao-user-card strong { font-size: 15px; color: #fff; overflow-wrap: anywhere; }
.feishao-user-card span { font-size: 12px; color: var(--muted); }
.feishao-user-card span b { color: #dfe9ff; font-weight: 650; }
.feishao-user-card button { margin-top: 5px; border: 1px solid rgba(255, 255, 255, .12); background: transparent; color: var(--muted); border-radius: 9px; padding: 8px; cursor: pointer; }
.feishao-user-card button:hover { color: #fff; border-color: rgba(255, 255, 255, .3); }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%, rgba(74, 110, 255, .2), transparent 38%), #07101d; }
.login-card { width: min(460px, 100%); padding: 34px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 22px; background: rgba(12, 24, 42, .94); box-shadow: 0 28px 80px rgba(0, 0, 0, .34); text-align: center; }
.login-card .brand-mark { margin: 0 auto 18px; }
.login-card h1 { margin: 0 0 10px; color: #fff; font-size: 28px; }
.login-card p { margin: 0; color: var(--muted); line-height: 1.8; }
.login-card .login-note { margin-top: 22px; padding: 14px; border-radius: 12px; background: rgba(73, 111, 255, .09); color: #c9d8ff; font-size: 13px; text-align: left; }
.login-card a { display: inline-flex; margin-top: 22px; padding: 11px 18px; border-radius: 10px; background: var(--primary); color: #fff; text-decoration: none; font-weight: 700; }
.local-launch { margin: 18px 0 0; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, .13); border-radius: 12px; color: #dce6ff; text-align: left; }
.local-launch summary { cursor: pointer; font-weight: 700; }
.local-launch form { display: grid; gap: 9px; margin: 12px 0 8px; }
.local-launch textarea { width: 100%; min-height: 92px; padding: 9px; resize: vertical; border: 1px solid rgba(255, 255, 255, .18); border-radius: 8px; color: #fff; background: rgba(255, 255, 255, .07); font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace; }
.local-launch button { justify-self: start; }
.local-launch small { color: #8fa0bb; }
main { min-height: 100vh; margin-left: var(--sidebar); padding: 0 28px 58px; }
.topbar { min-height: 112px; display: flex; justify-content: space-between; align-items: center; gap: 24px; border-bottom: 1px solid var(--line); }
.topbar h2 { margin: 3px 0 1px; font-size: 25px; line-height: 1.2; letter-spacing: -.4px; }
.topbar p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 12px; }
.mobile-user-strip { display: none; align-items: center; gap: 8px; margin-top: 9px; color: var(--muted); font-size: 10px; }
.mobile-user-strip button { min-height: 28px; padding: 4px 9px; border-color: var(--line); background: #fff; font-size: 10px; }
.eyebrow { margin: 0; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: 1.6px; }
.top-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
button { min-height: 39px; padding: 9px 15px; border-radius: 7px; font-weight: 700; cursor: pointer; transition: background .16s, border-color .16s, opacity .16s; }
button:disabled { opacity: .43; cursor: not-allowed; }
button.primary { color: #fff; background: var(--green); }
button.primary:hover:not(:disabled) { background: var(--green-dark); }
button.ghost { color: var(--ink); border: 1px solid #ced9d2; background: #fff; }
button.ghost:hover:not(:disabled) { border-color: #a9bbb0; background: #f8faf9; }
button.danger-outline { color: var(--red); border: 1px solid #dfbbb8; background: #fff; }
button.danger-outline:hover:not(:disabled) { background: var(--red-soft); }
.safety-banner { margin: 18px 0; padding: 11px 15px; display: flex; gap: 13px; border: 1px solid #eed8ad; border-left: 4px solid var(--amber); border-radius: 8px; color: #725c35; background: var(--amber-soft); font-size: 12px; }
.safety-banner b { color: #7f5310; white-space: nowrap; }
.notice { margin: -4px 0 18px; padding: 10px 14px; border-radius: 7px; color: #0f5c40; background: var(--green-soft); }
.notice.bad { color: #8e302d; background: var(--red-soft); }
.view { display: none; }
.view.active { display: block; animation: reveal .18s ease; }
@keyframes reveal { from { opacity: .45; transform: translateY(3px); } }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.metrics article, .panel, .form-band { border: 1px solid var(--line); border-radius: 10px; background: var(--card); box-shadow: var(--shadow); }
.metrics article { min-height: 116px; padding: 17px 18px; position: relative; overflow: hidden; }
.metrics article::after { content: ""; position: absolute; inset: auto -21px -31px auto; width: 66px; height: 66px; border-radius: 50%; background: #f1f6f3; }
.metrics span { display: block; color: var(--muted); font-size: 11px; }
.metrics strong { display: block; margin: 7px 0 2px; font-size: 20px; line-height: 1.3; word-break: break-word; }
.metrics small { position: relative; z-index: 1; color: #89968f; font-size: 10px; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.warning { color: var(--amber) !important; }
.warn { color: var(--amber) !important; }
.grid { display: grid; gap: 12px; margin-bottom: 12px; }
.grid.two-one { grid-template-columns: 1.65fr 1fr; }
.grid.equal { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel { padding: 19px 20px; margin-bottom: 12px; }
.grid > .panel { margin-bottom: 0; }
.panel-head, .band-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 15px; }
.panel h3, .form-band h3 { margin: 2px 0 0; font-size: 17px; }
.badge { display: inline-flex; align-items: center; min-height: 26px; padding: 3px 9px; border-radius: 99px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 800; white-space: nowrap; }
.badge.muted { color: var(--muted); background: #eef2ef; }
.badge.bad { color: var(--red); background: var(--red-soft); }
.badge.amber { color: #8d5d12; background: #fff2d9; }
.detail-list { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 26px; }
.detail-list > div { min-width: 0; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.detail-list > div.wide { grid-column: 1 / -1; }
.detail-list dt { margin: 0 0 3px; color: var(--muted); font-size: 10px; }
.detail-list dd { margin: 0; font-size: 12px; font-weight: 650; word-break: break-word; }
.event-log { max-height: 410px; overflow: auto; }
.event-row { display: grid; grid-template-columns: 150px 62px minmax(0, 1fr); gap: 12px; padding: 10px 5px; border-bottom: 1px solid var(--line-soft); align-items: start; }
.event-row time, .event-row em { color: var(--muted); font-size: 10px; font-style: normal; }
.event-row em { font-weight: 800; }
.event-row em.error { color: var(--red); }
.event-row em.warning { color: var(--amber); }
.event-row p { margin: 0; font-size: 12px; word-break: break-word; }
.empty { margin: 0; padding: 24px 8px; color: var(--muted); text-align: center; }
.settings-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.form-band { min-width: 0; padding: 21px 22px; }
.band-title > span { color: var(--muted); font-size: 10px; }
.band-title .locked { color: var(--green); padding: 4px 8px; border-radius: 5px; background: var(--green-soft); }
.form-grid { display: grid; gap: 13px; }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid.five { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.form-grid.six { grid-template-columns: repeat(6, minmax(0, 1fr)); }
label { min-width: 0; color: #53625b; font-size: 11px; font-weight: 650; }
label small { display: block; min-height: 30px; margin-top: 5px; color: #8a9790; font-size: 9px; font-weight: 400; line-height: 1.45; }
input, select { width: 100%; height: 40px; margin-top: 6px; padding: 8px 10px; border: 1px solid #cbd7d0; border-radius: 6px; outline: 0; color: var(--ink); background: #fff; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
input:disabled, select:disabled { color: #87938d; background: #f1f4f2; }
.ladder-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 14px; }
.ladder-summary div { padding: 11px 13px; border-radius: 7px; background: #f3f6f4; }
.ladder-summary span { display: block; color: var(--muted); font-size: 9px; }
.ladder-summary strong { display: block; margin-top: 3px; font-size: 12px; }
.table-wrap { width: 100%; max-width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th { padding: 10px 9px; border-bottom: 1px solid #dce4df; color: var(--muted); background: #f7f9f8; font-size: 9px; letter-spacing: .5px; }
td { padding: 10px 9px; border-bottom: 1px solid var(--line-soft); font-size: 11px; }
td code { color: #46564e; font: 10px ui-monospace, SFMono-Regular, Consolas, monospace; }
.ladder-table input { width: 110px; height: 34px; margin: 0; }
.ladder-profit-cell small { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.ladder-table tr.disabled-row { opacity: .43; }
.level-dot { display: inline-grid; width: 24px; height: 24px; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 9px; font-weight: 800; }
.enable-mark { color: var(--green); font-weight: 800; }
.disabled-row .enable-mark { color: var(--muted); }
.rule-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.rule-chips span { padding: 7px 10px; border: 1px solid #dce5df; border-radius: 6px; color: #5d6c65; background: #f7f9f8; font-size: 10px; }
.form-actions { position: sticky; bottom: 0; z-index: 8; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border: 1px solid var(--line); border-radius: 9px; background: rgba(255, 255, 255, .94); box-shadow: 0 -7px 25px rgba(29, 51, 40, .08); backdrop-filter: blur(8px); }
.form-actions p { margin: 0; color: var(--muted); font-size: 10px; }
.form-actions > div { display: flex; gap: 8px; }
.flow-list, .safety-list { margin: 0; padding: 0; list-style: none; }
.flow-list { counter-reset: flow; }
.flow-list li { counter-increment: flow; position: relative; min-height: 58px; padding: 2px 0 13px 45px; }
.flow-list li::before { content: counter(flow); position: absolute; left: 0; top: 0; width: 29px; height: 29px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--green); font-size: 10px; font-weight: 800; }
.flow-list li:not(:last-child)::after { content: ""; position: absolute; left: 14px; top: 29px; bottom: 0; border-left: 1px dashed #b8c9bf; }
.flow-list b, .flow-list span { display: block; }
.flow-list b { font-size: 12px; }
.flow-list span { color: var(--muted); font-size: 10px; }
.safety-list li { position: relative; padding: 10px 0 10px 22px; border-bottom: 1px solid var(--line-soft); color: #53625b; font-size: 11px; }
.safety-list li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 900; }
#toast { position: fixed; z-index: 99; right: 25px; bottom: 25px; max-width: min(430px, calc(100vw - 32px)); padding: 12px 16px; border-radius: 7px; color: #fff; background: #17231e; box-shadow: 0 15px 40px rgba(0, 0, 0, .22); opacity: 0; transform: translateY(9px); transition: .2s; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }
#toast.bad { background: #8c3431; }
dialog { width: min(470px, calc(100vw - 30px)); padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; box-shadow: 0 24px 80px rgba(9,30,19,.28); }
dialog::backdrop { background: rgba(8,24,16,.5); backdrop-filter: blur(2px); }
dialog form { padding: 22px; display: grid; gap: 15px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.dialog-head h3 { margin: 2px 0 0; }
.dialog-head button { width: auto; }
.dialog-note { padding: 11px 12px; border-left: 3px solid var(--green); color: var(--muted); background: var(--green-soft); font-size: 10px; line-height: 1.7; }
.dialog-note.locked { border-left-color: var(--amber); color: #725c35; background: var(--amber-soft); }
.switch-field { min-height: 62px; padding: 12px 13px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border: 1px solid var(--line); border-radius: 8px; }
.switch-field span, .switch-field b, .switch-field small { display: block; }
.switch-field b { font-size: 12px; }
.switch-field small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.switch-field input { width: 40px; height: 21px; margin: 0; accent-color: var(--green); }
@media (max-width: 1180px) {
  .form-grid.six { grid-template-columns: repeat(3, 1fr); }
  .form-grid.four, .form-grid.five { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 920px) {
  :root { --sidebar: 78px; }
  .sidebar { padding: 24px 10px 16px; }
  .brand { justify-content: center; padding: 0 0 23px; }
  .brand > div:last-child, .side-card, .connection span, .instance-switcher, .broker-switcher, .feishao-user-card { display: none; }
  .mobile-user-strip { display: flex; }
  .nav-item { justify-content: center; padding: 12px 0; font-size: 0; }
  .nav-item span { font-size: 18px; }
  .connection { justify-content: center; padding: 20px 0 0; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.two-one, .grid.equal { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  :root { --sidebar: 0px; }
  .sidebar { position: sticky; top: 0; width: 100%; height: 61px; padding: 8px 11px; flex-direction: row; align-items: center; }
  .brand { padding: 0 7px 0 0; }
  .brand-mark { width: 37px; height: 37px; }
  nav { flex: 1; display: flex; justify-content: flex-end; gap: 3px; }
  .nav-item, .nav-item.active { width: 42px; padding: 7px 0; }
  .connection { display: none; }
  main { margin-left: 0; padding: 0 14px 42px; }
  .topbar { min-height: auto; padding: 19px 0 14px; align-items: flex-start; flex-direction: column; gap: 13px; }
  .topbar h2 { font-size: 21px; }
  .top-actions { width: 100%; justify-content: flex-start; }
  .top-actions button { flex: 1 1 calc(50% - 4px); padding-left: 8px; padding-right: 8px; }
  .safety-banner { display: block; margin-top: 13px; }
  .safety-banner b { display: block; margin-bottom: 3px; }
  .metrics { gap: 8px; }
  .metrics article { min-height: 104px; padding: 14px; }
  .metrics strong { font-size: 17px; }
  .panel, .form-band { padding: 16px; }
  .detail-list { grid-template-columns: 1fr; }
  .detail-list > div.wide { grid-column: auto; }
  .form-grid.four, .form-grid.five, .form-grid.six { grid-template-columns: 1fr; }
  .ladder-summary { grid-template-columns: 1fr; }
  .event-row { grid-template-columns: 1fr; gap: 2px; }
  .form-actions { align-items: stretch; flex-direction: column; }
  .form-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
  .form-actions button { width: 100%; }
}
@media (max-width: 390px) {
  .metrics { grid-template-columns: 1fr; }
  .top-actions button { flex-basis: 100%; }
}
