:root {
  --brand: #116C7E;
  --brand-2: #18A5AC;
  --brand-soft: #E6F3F4;
  --up: #D93A3A;
  --up-soft: #FDEDED;
  --down: #128A5B;
  --down-soft: #E8F6EF;
  --ink: #12262C;
  --ink-2: #3C5A62;
  --muted: #708C93;
  --card: rgba(255, 255, 255, .74);
  --card-solid: #FFFFFF;
  --line: rgba(17, 108, 126, .13);
  --line-2: rgba(17, 108, 126, .07);
  --shadow: 0 12px 38px rgba(18, 68, 80, .09), 0 2px 8px rgba(18, 68, 80, .05);
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: #F3F8FA;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(18px);
  pointer-events: none;
}
body::before {
  width: 720px; height: 720px; top: -320px; left: -180px;
  background: radial-gradient(circle, rgba(24, 165, 172, .24) 0%, rgba(24, 165, 172, 0) 68%);
}
body::after {
  width: 780px; height: 780px; top: 120px; right: -300px;
  background: radial-gradient(circle, rgba(99, 133, 220, .16) 0%, rgba(99, 133, 220, 0) 68%);
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 26px 22px 60px; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.logo {
  width: 44px; height: 44px; border-radius: 13px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  box-shadow: 0 8px 20px rgba(17, 108, 126, .25);
  color: #fff; font-size: 23px; font-weight: 800; letter-spacing: -.04em;
}
.title-block h1 { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.title-block p { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--down-soft); color: var(--down); border: 1px solid rgba(18, 138, 91, .16);
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.running .dot { animation: pulse 1.8s ease-in-out infinite; }
.badge.paused { background: #F1F3F4; color: #6C7A80; border-color: rgba(0,0,0,.06); }
.badge.offline { background: #FFF4E5; color: #A66812; border-color: rgba(166,104,18,.18); }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.72); } }

button { font-family: inherit; cursor: pointer; }
.btn {
  border: 1px solid var(--line); background: rgba(255,255,255,.85); color: var(--ink-2);
  padding: 8px 14px; border-radius: 10px; font-size: 12.5px; font-weight: 650;
  transition: all .18s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); transform: translateY(-1px); }
.btn.primary { background: linear-gradient(140deg, var(--brand), #15909B); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(17,108,126,.22); }
.btn.primary:hover { color: #fff; filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--up); border-color: rgba(217,58,58,.2); }
.btn.sm { padding: 5px 10px; font-size: 11.5px; border-radius: 8px; }
.btn[hidden] { display: none; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid rgba(255,255,255,.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.card-head h2 { margin: 0; font-size: 14.5px; font-weight: 720; letter-spacing: -.01em; }
.card-head .sub { font-size: 11.5px; color: var(--muted); font-weight: 500; margin-left: auto; text-align: right; }
.chip {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-size: 13px; font-weight: 800; flex: 0 0 auto;
}

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi { padding: 17px 18px; position: relative; overflow: hidden; }
.kpi::after {
  content: ""; position: absolute; width: 130px; height: 130px; right: -55px; top: -65px;
  border-radius: 50%; background: radial-gradient(circle, rgba(24,165,172,.12), transparent 70%);
}
.kpi .label { font-size: 11.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 29px; font-weight: 780; letter-spacing: -.04em; line-height: 1.25; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .value.small { font-size: 22px; }
.kpi .unit { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.kpi .foot { font-size: 11.5px; color: var(--muted); margin-top: 5px; font-variant-numeric: tabular-nums; }
.up { color: var(--up) !important; }
.down { color: var(--down) !important; }
.thr-row { display: flex; gap: 8px; margin-top: 8px; }
.thr-box { flex: 1; background: rgba(255,255,255,.66); border: 1px solid var(--line-2); border-radius: 10px; padding: 7px 9px; }
.thr-box .t { font-size: 10.5px; font-weight: 650; color: var(--muted); }
.thr-box .v { font-size: 16px; font-weight: 750; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.thr-box.buy .v { color: var(--down); }
.thr-box.sell .v { color: var(--up); }

/* ---------- main grid ---------- */
.grid { display: grid; grid-template-columns: minmax(0, 1.32fr) minmax(340px, 1fr); gap: 16px; align-items: start; }
.col-left, .col-right { min-width: 0; }

/* ---------- chart ---------- */
.chart-wrap { position: relative; height: 268px; width: 100%; }
#chart { width: 100%; height: 100%; display: block; }
.chart-empty {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--muted); font-size: 12.5px; text-align: center; pointer-events: none;
}
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 12px; font-size: 11.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dash { background: none; border-top: 2px dashed var(--brand); height: 0; }
.legend i.buy { background: var(--down); }
.legend i.sell { background: var(--up); }

/* ---------- quote detail ---------- */
.quote-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.quote-item { background: rgba(255,255,255,.6); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 11px; }
.quote-item .t { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.quote-item .v { font-size: 15px; font-weight: 720; font-variant-numeric: tabular-nums; }
.quote-item.active { border-color: rgba(17,108,126,.35); background: var(--brand-soft); }

/* ---------- forms ---------- */
.form-group { margin-bottom: 15px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 11.5px; font-weight: 680; color: var(--ink-2); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.form-label .hint { font-weight: 500; color: var(--muted); font-size: 10.5px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row.three { grid-template-columns: 1fr 1fr 1fr; }
input[type="text"], input[type="number"], input[type="url"], select {
  width: 100%; padding: 8px 10px; border-radius: 9px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--line); background: rgba(255,255,255,.9); color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
  font-variant-numeric: tabular-nums;
}
input:focus, select:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(24,165,172,.13); }
input:disabled { background: #F1F5F6; color: var(--muted); }
select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' fill='none' stroke='%23116C7E' stroke-width='1.6' stroke-linecap='round'/></svg>"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 26px; }
.seg { display: inline-flex; background: rgba(255,255,255,.75); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; width: 100%; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 11.5px; font-weight: 650; padding: 6px 4px; border-radius: 7px; transition: all .15s; }
.seg button.on { background: var(--brand); color: #fff; box-shadow: 0 3px 8px rgba(17,108,126,.22); }
.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; padding: 3px 0; }
.check input { width: 15px; height: 15px; accent-color: var(--brand); cursor: pointer; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; }
.divider { height: 1px; background: var(--line); margin: 17px 0; opacity: .8; }
.section-title { font-size: 11px; font-weight: 750; color: var(--brand); letter-spacing: .06em; text-transform: uppercase; margin: 0 0 11px; }
.note { font-size: 11px; color: var(--muted); line-height: 1.6; margin-top: 7px; }
.note strong { color: var(--ink-2); }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- log ---------- */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { text-align: left; font-size: 10.5px; font-weight: 700; color: var(--muted); letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 9px 10px; border-bottom: 1px solid var(--line-2); font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 10.5px; font-weight: 700; }
.pill.buy { background: var(--down-soft); color: var(--down); }
.pill.sell { background: var(--up-soft); color: var(--up); }
.empty-log { text-align: center; color: var(--muted); padding: 26px 0; font-size: 12px; }

/* ---------- help ---------- */
details.help { margin-top: 16px; }
details.help summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--brand); list-style: none; display: flex; align-items: center; gap: 8px; }
details.help summary::-webkit-details-marker { display: none; }
details.help summary::before { content: "▸"; font-size: 12px; transition: transform .2s; }
details.help[open] summary::before { transform: rotate(90deg); }
.help-body { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.help-step { background: rgba(255,255,255,.6); border: 1px solid var(--line-2); border-radius: 12px; padding: 13px 14px; }
.help-step h3 { margin: 0 0 7px; font-size: 12.5px; color: var(--ink); }
.help-step ol, .help-step ul { margin: 0; padding-left: 17px; color: var(--ink-2); font-size: 11.5px; line-height: 1.75; }
.help-step .num { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-size: 10.5px; font-weight: 800; margin-right: 5px; }
.disclaimer { margin-top: 14px; font-size: 11px; color: var(--muted); background: rgba(255,255,255,.55); border-left: 3px solid var(--brand-2); padding: 10px 13px; border-radius: 0 8px 8px 0; }

/* ---------- alert overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 90; display: none; place-items: center;
  background: rgba(12, 38, 44, .42); backdrop-filter: blur(6px); padding: 20px;
}
.overlay.show { display: grid; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.alert-card {
  width: min(460px, 100%); background: #fff; border-radius: 22px; padding: 26px;
  box-shadow: 0 30px 80px rgba(10, 40, 48, .3); text-align: center;
  border-top: 5px solid var(--brand); animation: rise .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { transform: translateY(18px) scale(.97); opacity: .5; } to { transform: none; opacity: 1; } }
.alert-card.buy { border-top-color: var(--down); }
.alert-card.sell { border-top-color: var(--up); }
.alert-icon { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 14px; font-size: 27px; font-weight: 800; }
.alert-card.buy .alert-icon { background: var(--down-soft); color: var(--down); }
.alert-card.sell .alert-icon { background: var(--up-soft); color: var(--up); }
.alert-card h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.02em; }
.alert-card .price { font-size: 32px; font-weight: 800; letter-spacing: -.04em; font-variant-numeric: tabular-nums; margin: 12px 0 4px; }
.alert-card .msg { font-size: 13px; color: var(--ink-2); line-height: 1.75; margin: 10px 0 18px; }
.alert-card .meta { font-size: 11px; color: var(--muted); margin-bottom: 16px; }
.alert-card .btns { display: flex; gap: 9px; justify-content: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px);
  background: rgba(18, 38, 44, .94); color: #fff; padding: 10px 18px; border-radius: 11px;
  font-size: 12.5px; z-index: 120; opacity: 0; pointer-events: none; transition: all .25s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.footer { text-align: center; color: var(--muted); font-size: 11px; margin-top: 24px; }

@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .help-body { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .wrap { padding: 16px 13px 44px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 23px; }
  .card { padding: 16px; }
  .quote-grid { grid-template-columns: 1fr 1fr; }
  .row.three { grid-template-columns: 1fr 1fr; }
  .top-actions { width: 100%; margin-left: 0; }
  .title-block h1 { font-size: 17px; }
  .chart-wrap { height: 220px; }
}
