:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #949499;
  --line: #e5e5e7;
  --soft: #f5f5f7;
  --green: #2b9a4b;
  --amber: #d99100;
  --red: #d92d20;
  --redsoft: #fff0ee;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; background: #fff; color: var(--ink); font: 14px/1.45 var(--sans); font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; }
button:focus-visible { outline: 3px solid rgba(0, 113, 227, .2); outline-offset: 2px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 0; }
[hidden] { display: none !important; }

.shell { width: min(1180px, calc(100% - 48px)); margin: auto; padding: 30px 0 40px; }
.titlebar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 4px 2px 22px; }
h1 { margin: 0; font-size: 25px; line-height: 1.15; font-weight: 650; letter-spacing: -.025em; }
.subtitle { display: flex; align-items: center; gap: 8px; margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.dot { position: relative; width: 7px; height: 7px; flex: none; border-radius: 50%; }
.dot.normal { color: var(--green); background: var(--green); }
.dot.pulse::after { content: ""; position: absolute; inset: -4px; border: 1px solid currentColor; border-radius: 50%; animation: heartbeat 2.4s ease-out infinite; }

.header-actions { display: flex; gap: 8px; }
.button { height: 34px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid #d2d2d4; border-radius: 8px; padding: 0 13px; color: var(--ink); background: #fff; cursor: pointer; font-size: 12px; transition: background-color .15s, border-color .15s; }
.button:hover { border-color: #bdbdc0; background: #fafafa; }
.button:disabled { opacity: .55; cursor: wait; }
.button svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button-primary { color: #fff; border-color: var(--ink); background: var(--ink); }
.button-primary:hover { color: #fff; border-color: #353537; background: #353537; }

.statusline { display: flex; align-items: center; gap: 7px; min-height: 37px; padding: 0 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.statusline b { min-width: 35px; color: #515154; font-weight: 500; }
.status-divider { color: #c4c4c7; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 7px 0 6px; }
.segments { display: inline-flex; padding: 3px; border-radius: 9px; background: #ececee; }
.filter { position: relative; min-width: 68px; height: 32px; padding: 0 15px; border: 0; border-radius: 7px; color: #515154; background: transparent; cursor: pointer; font-size: 12px; }
.filter.active { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .13), 0 0 0 .5px rgba(0, 0, 0, .08); font-weight: 580; }
.sort-hint { color: var(--faint); font-size: 11px; }

.summary { display: grid; grid-template-columns: 100px 110px 110px 180px; align-items: center; min-height: 34px; padding: 0 2px; }
.sum { display: flex; align-items: center; gap: 5px; min-width: 0; }
.sum-label, .sum-value { overflow: hidden; font-size: 11px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.sum-label { color: var(--muted); }
.sum-value { color: var(--ink); }
.alert-value { color: var(--red); }

.frame { overflow: visible; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
th { height: 40px; padding: 0 14px; color: var(--muted); background: #fafafa; border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; font-weight: 560; }
th:first-child { border-radius: 10px 0 0; }
th:last-child { border-radius: 0 10px 0 0; }
td { height: 66px; padding: 9px 14px; border-bottom: 1px solid #f1f1f2; vertical-align: middle; overflow: visible; }
tbody tr { transition: background-color .2s; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafafa; }
tbody tr.triggered { background: #fffafa; }
tbody tr.triggered:hover { background: #fff7f6; }
tbody tr.paused { opacity: .56; }
.strategy-col { width: 21%; }
.relation-col { width: 23%; }
.price-col { width: 18%; }
.return-col { width: 13%; }
.threshold-col { width: 10%; }
.state-col { width: 10%; }
.action-col { width: 78px; }
.num { text-align: right; }

.strategy-primary > div { display: flex; align-items: center; gap: 7px; min-width: 0; }
.strategy-primary h3 { margin: 0; overflow: hidden; font-size: 13px; font-weight: 570; text-overflow: ellipsis; white-space: nowrap; }
.type-badge { flex: none; padding: 1px 5px; border: 1px solid #dedee1; border-radius: 999px; color: #77777c; background: #fafafa; font-size: 8px; letter-spacing: .02em; }
.refreshed-time { display: block; margin-top: 4px; color: var(--faint); font-size: 9px; white-space: nowrap; }
.symbol-line { margin: 0; overflow: hidden; color: #444448; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.signal-message { margin: 3px 0 0; overflow: hidden; color: var(--faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.triggered .signal-message { color: var(--red); }
.price-row { padding-top: 6px; padding-bottom: 6px; }
.price-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; line-height: 1.45; }
.price-chip + .price-chip { margin-top: 3px; }
.price-chip span { overflow: hidden; color: var(--faint); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.price-chip b { color: #3a3a3d; font-size: 11px; font-weight: 500; }
.metric-cell small { display: none; }
.metric-value { display: block; color: #363639; font-size: 13px; font-weight: 550; }
.triggered .metric-value { color: var(--red); }
.progress-track { position: relative; width: 58px; height: 3px; margin: 5px 0 0 auto; overflow: hidden; border-radius: 3px; background: #ececee; }
.progress-track i { display: block; height: 100%; background: #85858a; transition: width .4s ease; }
.triggered .progress-track i { background: var(--red); }
.progress-track span { display: none; }
.threshold-value { font-size: 12px; font-weight: 450; }
.state-badge { display: inline-flex; align-items: center; gap: 6px; color: #55555a; font-size: 10px; white-space: nowrap; }
.state-badge::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--green); }
.triggered .state-badge { color: var(--red); }
.triggered .state-badge::before { background: var(--red); }
.paused .state-badge::before { background: #a0a0a5; }
.action-cell { position: relative; padding: 0 8px; text-align: right; white-space: nowrap; }
.card-heading { position: relative; display: inline-block; vertical-align: middle; }
.icon-button { display: inline-grid; width: 31px; height: 31px; padding: 0; place-items: center; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; }
.icon-button:hover { color: var(--ink); background: #f1f1f3; }
.icon-button:disabled { opacity: .48; cursor: wait; }
.icon-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.refresh-one.loading svg, .button.loading svg { animation: spin .72s linear infinite; }
.menu-button { font-size: 14px; letter-spacing: 1px; }
.card-menu { position: absolute; z-index: 5; top: 34px; right: 0; width: 132px; padding: 5px; border: 1px solid #dedee1; border-radius: 8px; background: #fff; box-shadow: 0 10px 30px rgba(0, 0, 0, .14); text-align: left; }
.card-menu button { display: block; width: 100%; height: 31px; padding: 0 9px; border: 0; border-radius: 5px; color: #454548; background: transparent; cursor: pointer; text-align: left; font-size: 11px; }
.card-menu button:hover { background: var(--soft); }
.card-menu .danger { color: var(--red); }

.empty-state { padding: 70px 24px; color: var(--muted); text-align: center; }
.empty-state h3 { margin: 0 0 6px; color: var(--ink); font-size: 15px; font-weight: 600; }
.empty-state p { margin: 0 0 18px; font-size: 12px; }
.foot { display: flex; justify-content: space-between; gap: 18px; padding: 13px 4px 0; color: var(--faint); font-size: 11px; }

.strategy-dialog { width: min(620px, calc(100% - 32px)); max-height: min(780px, calc(100dvh - 32px)); padding: 0; border: 0; border-radius: 14px; color: var(--ink); background: #fff; box-shadow: 0 22px 60px rgba(0, 0, 0, .22); }
.strategy-dialog::backdrop { background: rgba(0, 0, 0, .23); }
.strategy-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; animation: dialog-in .18s ease-out; }
.strategy-dialog form { display: contents; }
.dialog-head { display: flex; align-items: start; justify-content: space-between; padding: 23px 24px 18px; border-bottom: 1px solid var(--line); }
.section-kicker { display: none; }
.dialog-head h2 { margin: 0; font-size: 19px; line-height: 1.2; font-weight: 650; }
.dialog-head .close-dialog { margin: -5px -5px 0 0; font-size: 20px; font-weight: 300; }
.form-body { display: grid; gap: 17px; min-height: 0; padding: 20px 24px 22px; overflow-y: auto; }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 0; padding: 3px; border: 0; border-radius: 9px; background: #ececee; }
.type-switch legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.type-switch label { min-width: 0; cursor: pointer; }
.type-switch input { position: absolute; opacity: 0; }
.type-switch span { min-height: 51px; display: flex; flex-direction: column; justify-content: center; padding: 6px 12px; border-radius: 7px; color: var(--muted); text-align: center; }
.type-switch b { color: #515154; font-size: 11px; font-weight: 560; }
.type-switch small { margin-top: 2px; color: var(--faint); font-size: 8px; }
.type-switch input:checked + span { color: var(--ink); background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .13), 0 0 0 .5px rgba(0, 0, 0, .08); }
.type-switch input:checked + span b { color: var(--ink); }
.type-switch.editing { opacity: .58; pointer-events: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.field { display: grid; gap: 6px; }
.field > span { padding-left: 2px; color: var(--muted); font-size: 11px; }
.field > span i { color: var(--faint); font-style: normal; }
.field input, .field select, .field textarea { width: 100%; border: 1px solid transparent; border-radius: 8px; color: var(--ink); background: #f2f2f4; font-size: 12px; transition: border-color .15s, background-color .15s; }
.field input, .field select { height: 40px; padding: 0 12px; }
.field textarea { min-height: 72px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
.field input:hover, .field select:hover, .field textarea:hover { background: #ededf0; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: #77777c; background: #fff; }
.field input::placeholder, .field textarea::placeholder { color: #a7a7ac; }
.field > small { margin-top: -3px; padding-left: 2px; color: var(--faint); font-size: 9px; }
.input-unit { position: relative; }
.input-unit input { padding-right: 35px; }
.input-unit i { position: absolute; top: 12px; right: 12px; color: var(--faint); font-size: 10px; font-style: normal; }
.spread-explainer { display: grid; grid-template-columns: 38px 1fr; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 8px; color: #5f6260; background: #f3f7f4; }
.spread-explainer > span { display: grid; width: 36px; height: 28px; place-items: center; border-radius: 6px; color: #287b40; background: #e5f1e8; font-size: 9px; font-weight: 600; }
.spread-explainer p { margin: 0; font-size: 9px; line-height: 1.55; }
.spread-explainer b { display: block; color: #386142; font-size: 10px; }
.toggle-field { display: flex; align-items: center; justify-content: space-between; cursor: pointer; }
.toggle-field > span { display: grid; gap: 2px; }
.toggle-field b { font-size: 11px; font-weight: 560; }
.toggle-field small { color: var(--faint); font-size: 9px; }
.toggle-field input { position: absolute; opacity: 0; }
.toggle-field > i { position: relative; width: 39px; height: 23px; border-radius: 20px; background: #d7d7da; transition: background .15s; }
.toggle-field > i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .15s; }
.toggle-field input:checked + i { background: var(--green); }
.toggle-field input:checked + i::after { transform: translateX(16px); }
.reset-baseline { color: var(--muted); font-size: 10px; }
.reset-baseline input { accent-color: var(--green); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 16px; border-top: 1px solid var(--line); background: #fafafa; }

.toast-region { position: fixed; z-index: 50; bottom: 22px; left: 50%; display: grid; gap: 7px; pointer-events: none; transform: translateX(-50%); }
.toast { min-width: 220px; max-width: min(430px, calc(100vw - 32px)); padding: 10px 15px; border-radius: 9px; color: #fff; background: rgba(29, 29, 31, .92); box-shadow: 0 8px 28px rgba(0, 0, 0, .16); text-align: center; font-size: 12px; animation: toast-in .18s ease-out; }
.toast.error { background: rgba(176, 39, 30, .94); }

@keyframes heartbeat { 0%, 55%, 100% { opacity: 0; transform: scale(.65); } 18% { opacity: .45; transform: scale(1); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(6px) scale(.99); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

@media (max-width: 850px) {
  .relation-col, .relation-cell { display: none; }
  .strategy-col { width: 27%; }
  .price-col { width: 23%; }
  .return-col { width: 17%; }
  .threshold-col { width: 12%; }
  .state-col { width: 13%; }
}

@media (max-width: 640px) {
  .shell { width: 100%; padding: 18px 16px 28px; }
  .titlebar { align-items: flex-start; padding: 2px 2px 18px; }
  h1 { font-size: 22px; }
  .subtitle { font-size: 12px; }
  .header-actions .button-ghost { width: 34px; padding: 0; font-size: 0; }
  .toolbar { flex-wrap: wrap; gap: 6px; }
  .segments { display: grid; flex: 1 0 100%; grid-template-columns: repeat(4, 1fr); }
  .filter { min-width: 0; padding: 0 7px; }
  .sort-hint { display: none; }
  .summary { grid-template-columns: repeat(4, minmax(0, 1fr)); min-height: 40px; }
  .sum { display: block; min-width: 0; padding: 0 4px; }
  .sum:first-child { padding-left: 0; }
  .sum-label, .sum-value { display: block; font-size: 10px; }
  .sum-value { margin-top: 1px; }
  .status-divider:nth-of-type(2), #intervalMetric { display: none; }
  th, td { padding-left: 11px; padding-right: 11px; }
  td { height: 64px; }
  .strategy-col { width: auto; }
  .return-col { width: 88px; }
  .state-col { width: 74px; }
  .action-col { width: 68px; }
  .price-col, .price-row, .threshold-col, .threshold-cell { display: none; }
  .strategy-primary h3 { max-width: 150px; }
  .type-badge { display: none; }
  .progress-track { width: 48px; }
  .action-cell { padding-left: 2px; padding-right: 2px; }
  .foot { display: block; line-height: 1.7; }
  .foot span:last-child { display: none; }
  .form-grid, .type-switch { grid-template-columns: 1fr; }
  .type-switch { background: transparent; padding: 0; gap: 6px; }
  .type-switch span { border: 1px solid var(--line); background: #fafafa; }
  .dialog-head, .form-body { padding-left: 20px; padding-right: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .dot.pulse::after { display: none; animation: none; }
}
