/* MACD 控制台 — Notion 风格 */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --text: rgb(55, 53, 47);
  --text-soft: rgba(55, 53, 47, 0.7);
  --muted: rgba(55, 53, 47, 0.5);
  --subtle: rgba(55, 53, 47, 0.08);
  --hover: rgba(55, 53, 47, 0.04);
  --border: rgba(55, 53, 47, 0.09);
  --bg: #ffffff;
  --bg-soft: rgb(247, 246, 243);
  --accent: rgb(35, 131, 226);
  --accent-soft: rgba(35, 131, 226, 0.14);
  --green: rgb(68, 131, 97);
  --green-soft: rgba(68, 131, 97, 0.13);
  --red: rgb(212, 76, 71);
  --red-soft: rgba(212, 76, 71, 0.13);
  --amber: rgb(203, 145, 47);
  --amber-soft: rgba(203, 145, 47, 0.13);
  --input-bg: rgba(242, 241, 238, 0.6);
  --input-bg-hover: rgba(242, 241, 238, 1);
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; font-size: 0.92em; }

/* === Top nav === */
.topnav {
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topnav .inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 10px 32px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.topnav .brand {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topnav .links { display: flex; gap: 2px; flex: 1; }
.topnav .links a {
  color: var(--muted);
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 3px;
  transition: background .1s, color .1s;
  text-decoration: none;
}
.topnav .links a:hover { background: var(--hover); color: var(--text); }
.topnav .links a.active { background: var(--subtle); color: var(--text); font-weight: 500; }
.topnav .user { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

/* === Page === */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 56px 32px 96px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 36px;
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.2;
}
.page-head .subtitle { margin: 0; color: var(--muted); font-size: 14px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  line-height: 1.4;
  transition: background .1s;
  text-decoration: none;
}
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  padding: 6px 14px;
}
.btn.primary:hover { background: rgb(28, 110, 192); }
.btn.ghost { color: var(--muted); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 3px 9px; font-size: 13px; font-weight: 400; }

/* === Alerts === */
.flash {
  padding: 10px 14px;
  border-radius: 4px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 13.5px;
  margin-bottom: 24px;
}
.alert-danger {
  padding: 12px 14px;
  border-radius: 4px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13.5px;
  margin-bottom: 24px;
}
.alert-danger strong { font-weight: 600; }
.alert-danger ul { margin: 6px 0 0 18px; padding: 0; }

/* === Strategy cards === */
.cards { display: grid; gap: 14px; }
.card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 22px;
  background: #fff;
  transition: border-color .12s;
}
.card:hover { border-color: rgba(55, 53, 47, 0.22); }
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.005em;
  margin: 0;
}
.card-actions { display: flex; gap: 2px; flex-shrink: 0; }
.props {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 9px 18px;
  font-size: 13.5px;
  padding-top: 4px;
  border-top: 1px solid rgba(55, 53, 47, 0.06);
  padding: 14px 0 0;
}
.props .pk {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding-top: 3px;
  white-space: nowrap;
}
.props .pv {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  color: var(--text);
  min-width: 0;
}
.props .pv.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.props .pv .dash { color: var(--muted); }

/* Tags */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 3px;
  background: var(--subtle);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}
.tag.green { background: var(--green-soft); color: var(--green); }
.tag.red   { background: var(--red-soft); color: var(--red); }
.tag.blue  { background: var(--accent-soft); color: var(--accent); }
.tag.amber { background: var(--amber-soft); color: var(--amber); }

/* Empty */
.empty-state {
  padding: 64px 0;
  text-align: center;
  color: var(--muted);
}
.empty-state h3 { color: var(--text); font-weight: 500; margin: 0 0 6px; font-size: 16px; }

/* === Form === */
.form-wrap {
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.section h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.field > label .opt { color: var(--muted); font-weight: 400; margin-left: 4px; font-size: 12px; }
.field > .hint { font-size: 12.5px; color: var(--muted); }

.field input[type=text],
.field input[type=number],
.field select {
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 14px;
  color: var(--text);
  font-family: inherit;
  transition: background .1s, box-shadow .1s;
  appearance: none;
}
.field input:hover, .field select:hover { background: var(--input-bg-hover); }
.field input:focus, .field select:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.8);
}
.field select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath fill='%23737373' d='M0 0l4 5 4-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* Notion-style switch */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}
.toggle > input { position: absolute; opacity: 0; pointer-events: none; }
.toggle .track {
  width: 30px;
  height: 18px;
  background: rgba(55, 53, 47, 0.18);
  border-radius: 999px;
  position: relative;
  transition: background .12s;
  flex-shrink: 0;
}
.toggle .knob {
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left .12s;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
.toggle > input:checked + .track { background: var(--accent); }
.toggle > input:checked + .track .knob { left: 14px; }

/* Chip selector (周期、参数模式) */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--subtle);
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background .1s, color .1s;
  border: 1px solid transparent;
}
.chip:hover { background: rgba(55, 53, 47, 0.12); }
.chip input { display: none; }
.chip.green.active {
  background: var(--green-soft);
  color: var(--green);
}
.chip.red.active {
  background: var(--red-soft);
  color: var(--red);
}
.chip.extra {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--muted);
  cursor: default;
}

/* Param group */
.param-group { display: flex; flex-direction: column; gap: 18px; }
.param-field { display: flex; flex-direction: column; gap: 6px; }
.param-field .head {
  font-size: 13px;
  font-weight: 500;
}
.param-field .head .key { color: var(--muted); font-weight: 400; margin-left: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.param-field .inputs {
  display: grid;
  gap: 10px;
}
.param-field .sub {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.param-field input[type=number] {
  background: var(--input-bg);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 14px;
  font-family: ui-monospace, Menlo, monospace;
  width: 100%;
}
.param-field input:hover { background: var(--input-bg-hover); }
.param-field input:focus { outline: none; background: #fff; box-shadow: 0 0 0 2px rgba(35, 131, 226, 0.8); }
.param-field .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

.form-actions {
  margin-top: 8px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
}

/* === Health page === */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 32px;
  overflow: hidden;
}
.kpi {
  padding: 14px 16px;
  border-right: 1px solid var(--border);
}
.kpi:last-child { border-right: none; }
.kpi .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.kpi .value {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi .value.mono {
  font-family: ui-monospace, Menlo, monospace;
  font-weight: 500;
  font-size: 13px;
}
.kpi .value .date {
  display: block;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 13px;
  font-weight: 500;
}
.kpi .value .time {
  display: block;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 1px;
}
.kpi .sub {
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
}

/* === advanced details === */
details.advanced > summary {
  cursor: pointer;
  list-style: none;
  padding: 6px 0;
  color: var(--text);
  user-select: none;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary::before {
  content: '▸';
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform .15s;
}
details.advanced[open] > summary::before { transform: rotate(90deg); }
details.advanced h2 { margin: 0; }

/* === 持仓方向 select 着色 === */
select.side-select {
  font-weight: 600;
  transition: background .15s, border-color .15s, color .15s;
}
select.side-select.long {
  background: var(--green-soft);
  border-color: rgba(68, 131, 97, 0.4);
  color: var(--green);
}
select.side-select.long:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(68, 131, 97, 0.18);
}
select.side-select.short {
  background: var(--red-soft);
  border-color: rgba(212, 76, 71, 0.4);
  color: var(--red);
}
select.side-select.short:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(212, 76, 71, 0.18);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot.green { background: var(--green); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }

.callout {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.callout + .callout { margin-top: 12px; }
.callout .head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 10px;
}
.callout .head .sub { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--muted); margin-left: 8px; }

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(55, 53, 47, 0.05);
  white-space: nowrap;
  vertical-align: top;
}
.data-table td > div { white-space: nowrap; }
.data-table tr.row-stop td { color: var(--red); }
.data-table tr.row-stop td > div + div { opacity: 0.75; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--hover); }
.data-table td.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }

/* === Login === */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: #fff;
}
.login-card { max-width: 320px; width: 100%; }
.login-card h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}
.login-card .sub {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 28px;
}

/* helpers */
.muted { color: var(--muted); }
.foot-note { color: var(--muted); font-size: 12.5px; margin-top: 24px; }

@media (max-width: 720px) {
  .row2, .row3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .kpi { border-bottom: 1px solid var(--border); }
  .kpi:nth-child(2) { border-right: none; }
  .strategy-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .container { padding: 32px 20px 64px; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
