:root {
  color-scheme: light;
  --canvas: #f4f6f7;
  --white: #fff;
  --ink: #17262c;
  --muted: #54666d;
  --line: #dce5e6;
  --teal: #006452;
  --tint: #e6f4ee;
  --red: #a52334;
  --soft-red: #fff0f1;
  --amber: #8a5300;
  --soft-amber: #fff7e6;
  --sidebar: 224px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 14px/1.55 "Inter", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}

h1, h2, p, dl, dd { margin: 0; }
h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.2; letter-spacing: -.04em; }
h2 { font-size: 17px; line-height: 1.4; }
a { color: var(--teal); text-decoration: none; }
a, button, input, select { outline-offset: 3px; }
:focus-visible { outline: 2px solid #097a6a; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
small, .muted { color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #eef2f3; padding: 1px 5px; border-radius: 4px; }

.num, time, td { font-variant-numeric: tabular-nums; }
.up { color: var(--teal); }
.down { color: var(--red); }

.layout { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 22px 14px 16px;
}
.sidebar-head { display: flex; justify-content: space-between; align-items: flex-start; }
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 5px 7px 21px;
  color: var(--ink);
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
}
.mark {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 9px;
  background: #132c29;
  color: #d1fbea;
  font-size: 11px;
  letter-spacing: .06em;
  flex-shrink: 0;
}
.navigation { flex: 1; overflow: auto; }
.nav-label { margin: 16px 10px 6px; font-size: 11px; color: var(--muted); letter-spacing: .07em; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
  min-height: 42px;
  border-radius: 8px;
  padding: 7px 10px;
  color: #43545a;
}
.nav-link:hover { background: #f1f5f4; }
.nav-link[aria-current="page"] { background: var(--tint); color: var(--teal); font-weight: 700; }
.nav-link .icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  line-height: 1;
  font-size: 15px;
}
.sidebar-foot {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding: 14px 8px 2px;
  font-size: 12px;
}
.sidebar-foot b { display: block; font-size: 13px; margin-bottom: 3px; }

.workspace { min-width: 0; }
.topbar {
  min-height: 63px;
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 9px clamp(16px, 3.2vw, 44px);
  background: var(--white);
  border-bottom: 1px solid var(--line);
}
.top-actions, .actions, .row { display: flex; gap: 10px; align-items: center; }
.row { justify-content: space-between; }
.top-actions { justify-content: flex-end; flex-wrap: wrap; }
.breadcrumb { min-width: 0; display: flex; gap: 9px; align-items: center; font-size: 13px; white-space: nowrap; }

.status {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  padding: 5px 10px;
  border-radius: 6px;
  background: #eef2f3;
  color: #44565e;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ready { background: var(--tint); color: var(--teal); }
.status.attention { background: var(--soft-red); color: var(--red); }
.status.warn { background: var(--soft-amber); color: var(--amber); }

.topbar .nav-toggle, .sidebar .nav-close, .nav-overlay { display: none; }

main { max-width: 1370px; margin: 0 auto; padding: 24px clamp(16px, 3.2vw, 44px) 44px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin: 12px 0 22px;
}
.page-head p { margin-top: 6px; color: var(--muted); }

.alert, .statusline { margin-bottom: 13px; padding: 10px 14px; border-radius: 8px; overflow-wrap: anywhere; }
.alert { border: 1px solid #efc4ca; color: #8e2030; background: var(--soft-red); }
.alert a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.statusline {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 18px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  background: #eef2f3;
  font-size: 12px;
}
.statusline p { font-weight: 600; }

.progress-card {
  padding: clamp(18px, 3vw, 28px);
  background: #12332f;
  color: #fff;
  border-radius: 14px;
}
.progress-card .muted { color: #c6ded6; }
.progress-card .row { align-items: baseline; flex-wrap: wrap; }
.progress-amount {
  margin: 8px 0 4px;
  font-size: clamp(28px, 4.5vw, 44px);
  font-weight: 650;
  line-height: 1.12;
  letter-spacing: -.04em;
}
.hero-subgrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgb(255 255 255 / .14);
}
.hero-subgrid span { display: block; font-size: 12px; color: #c6ded6; }
.hero-subgrid b { display: block; margin-top: 3px; font-size: 16px; color: #fff; font-variant-numeric: tabular-nums; }

.panel, .card {
  min-width: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.card { padding: 15px 16px; }
.card b {
  display: block;
  margin: 7px 0 5px;
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.form-split { grid-template-columns: minmax(0, 1.45fr) minmax(260px, 1fr); }
.pad { padding: 19px 20px; }
.panel-title { margin-bottom: 12px; }
.text-link { font-size: 13px; font-weight: 650; }
.text-link:hover { text-decoration: underline; text-underline-offset: 3px; }

.facts > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #e8eeee;
}
.facts > div:last-child { border-bottom: none; padding-bottom: 2px; }
.facts dt { color: var(--muted); }
.facts dd { text-align: end; font-weight: 600; overflow-wrap: anywhere; }
.facts small { display: block; font-weight: normal; }
.hint { margin-top: 12px; color: var(--muted); font-size: 12px; }

.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.full { grid-column: 1 / -1; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
input, select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid #cad7d9;
  border-radius: 7px;
}
input[type="checkbox"] { width: 18px; min-height: 18px; height: 18px; accent-color: var(--teal); }
.check-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }

.actions { flex-wrap: wrap; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 650;
  border: 1px solid #cbd8d9;
  border-radius: 7px;
  background: var(--white);
  color: var(--ink);
  transition: transform .08s ease, opacity .15s ease, border-color .15s ease, background-color .15s ease;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:hover:not(:disabled) { border-color: var(--teal); }
.primary { background: var(--teal); color: #fff; border-color: var(--teal); }
.primary:hover:not(:disabled) { background: #004f41; }
.danger { background: var(--soft-red); border-color: #efc4ca; color: var(--red); }
.danger:hover:not(:disabled) { border-color: var(--red); }

.error { font-size: 13px; color: var(--red); margin-top: 11px; overflow-wrap: anywhere; }
.error:empty { display: none; }

.table-panel { overflow: hidden; }
.scroll { overflow: auto; max-height: min(680px, 64vh); }
.account-toolbar { row-gap: 12px; flex-wrap: wrap; }
.account-tabs button[aria-pressed="true"] { background: var(--tint); color: var(--teal); border-color: var(--teal); }

table { border-collapse: collapse; width: 100%; white-space: nowrap; font-size: 13px; }
th, td { text-align: start; padding: 11px 14px; border-bottom: 1px solid #e8eeee; }
th { position: sticky; top: 0; z-index: 1; background: #f1f5f5; color: #43545a; font-size: 12px; }
tr:hover td { background: #f7fbfa; }
.logs-table td:last-child { min-width: 320px; white-space: normal; overflow-wrap: anywhere; }

.empty {
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 180px;
  padding: 22px;
  text-align: center;
  gap: 8px;
}

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--canvas); }
.login-card { width: min(400px, 100%); padding: 28px 24px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; }
.login-card .brand { padding: 0 0 18px; }

.toast-stack {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 99;
  display: grid;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #17272e;
  box-shadow: 0 8px 24px rgb(17 30 35 / .18);
  animation: toastIn .16s ease-out;
}
.toast.ok { background: #0b6352; }
.toast.err { background: #b42336; }

.observer-svg {
  width: 100%;
  height: auto;
  display: block;
  background: #f9fbfa;
  border: 1px solid #e8eeee;
  border-radius: 9px;
}
.observer-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}
.observer-legend span { display: inline-flex; align-items: center; gap: 6px; }
.observer-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.tag-pill {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 700;
}
.tag-buy { background: var(--tint); color: var(--teal); }
.tag-sell { background: var(--soft-red); color: var(--red); }
.mid-row td { background: #12332f !important; color: #fff; font-weight: 700; }

.equity-plot {
  margin-top: 12px;
  border: 1px solid #e8eeee;
  border-radius: 9px;
  background: #f9fbfa;
  overflow: hidden;
}
.equity-svg { display: block; width: 100%; height: 240px; }
.runs-select-table tr[data-run-id] { cursor: pointer; }
.runs-select-table tr.selected td { background: #e3f4ee; }

@keyframes toastIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 1100px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .form-split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
  .layout { display: block; }
  .sidebar { display: none; position: fixed; inset: 0 auto 0 0; width: min(275px, 85vw); height: 100dvh; z-index: 6; }
  .menu-open .sidebar { display: flex; }
  .menu-open .nav-overlay { display: block; position: fixed; inset: 0; z-index: 5; border: 0; background: rgb(17 30 35 / .48); }
  .topbar .nav-toggle, .sidebar .nav-close { display: inline-flex; }
  .topbar { gap: 7px; min-height: 55px; }
  main { padding-top: 15px; }
  .split, .formgrid { grid-template-columns: minmax(0, 1fr); }
}
