:root {
  color-scheme: light;
  --ink: #202826;
  --muted: #68736f;
  --line: #d9dfdc;
  --surface: #ffffff;
  --canvas: #f2f5f3;
  --green: #166d52;
  --green-soft: #e4f1eb;
  --red: #a33c36;
  --red-soft: #f8e9e6;
  --amber: #8a5a13;
  --amber-soft: #f8efd9;
  --slate-soft: #edf0ef;
  --focus: #287d61;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: var(--canvas); }
button, input, textarea, select { font: inherit; }
button, input, textarea, select { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

.app-frame { min-height: 100vh; }
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 22px;
  color: #f7faf8;
  background: #222b28;
  border-bottom: 1px solid #39413e;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 650; }
.brand-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid #90c6ad;
  border-radius: 5px;
  color: #c2e7d2;
  font-size: 13px;
  font-weight: 700;
}
.topbar-state { display: flex; align-items: center; gap: 12px; color: #c2cbc7; font-size: 12px; }
.environment-label { padding: 3px 7px; border: 1px solid #61746b; border-radius: 4px; color: #c2e7d2; }
.connection-state { color: #b8c2bd; }
.operator-controls { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.operator-name { color: #d7dfdb; font-size: 12px; }
.button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover:not(:disabled) { background: #105b44; }
.button-secondary { color: #34413b; border-color: #c8d1cc; background: #fff; }
.button-secondary:hover:not(:disabled) { background: #f5f8f6; }
.button-quiet { min-height: 30px; padding: 4px 8px; color: #e0e7e3; border-color: #68746e; background: transparent; }

.login-view { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 28px 16px; }
.login-panel { width: min(100%, 390px); padding: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.section-kicker { color: var(--green); font-size: 10px; font-weight: 750; }
.login-panel h1 { margin: 7px 0 22px; font-size: 22px; font-weight: 680; }
form { min-width: 0; }
.login-panel form { display: grid; gap: 8px; }
label { color: #3c4843; font-size: 12px; font-weight: 600; }
input, textarea, select {
  min-width: 0;
  border: 1px solid #cbd3cf;
  border-radius: 4px;
  background: #fff;
}
input, select { min-height: 38px; padding: 7px 9px; }
textarea { padding: 10px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.5; }
.login-submit { margin-top: 9px; }
.form-message { min-height: 20px; margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }

.app-shell { min-height: calc(100vh - 56px); display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; min-height: calc(100vh - 56px); padding: 20px 12px 15px; border-right: 1px solid var(--line); background: #e9eeeb; }
.sidebar-heading { padding: 0 10px 12px; color: #7a8580; font-size: 10px; font-weight: 750; }
.side-nav { display: grid; gap: 4px; }
.nav-item { min-height: 38px; padding: 8px 10px; border: 0; border-radius: 4px; color: #47534e; background: transparent; cursor: pointer; text-align: left; font-size: 13px; font-weight: 550; }
.nav-item:hover { background: #dde5e0; }
.nav-item.active { color: #145c45; background: #d5e8dd; font-weight: 700; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 11px 10px; border-top: 1px solid #d5dcd8; color: #53605a; font-size: 11px; }
.state-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: var(--amber); }
.workspace { min-width: 0; padding: 24px clamp(16px, 3vw, 38px) 18px; }
.workspace-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.workspace-heading h1 { margin: 4px 0 0; font-size: 23px; font-weight: 680; }
.heading-actions { display: flex; align-items: center; gap: 12px; }
.muted-text { color: var(--muted); font-size: 11px; }
.blocker-strip { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 14px; padding: 10px 12px; border: 1px solid #ead6a7; border-radius: 5px; color: #684812; background: #fbf4e4; font-size: 12px; }
.blocker-chip { padding: 2px 7px; border: 1px solid #e7d4a9; border-radius: 4px; background: #fffaf0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric-tile { min-width: 0; min-height: 100px; padding: 14px 15px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.metric-label { color: #64706a; font-size: 11px; }
.metric-value { overflow: hidden; margin-top: 8px; font-size: 22px; font-variant-numeric: tabular-nums; font-weight: 660; text-overflow: ellipsis; white-space: nowrap; }
.metric-value-small { font-size: 16px; }
.metric-meta { overflow: hidden; margin-top: 4px; color: #7a8580; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.content-section { margin-top: 20px; padding-top: 17px; border-top: 1px solid #d1d9d5; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 11px; }
.section-heading h2 { margin: 0; font-size: 15px; font-weight: 670; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.count-label { padding: 3px 7px; border: 1px solid var(--line); border-radius: 4px; color: #65716b; background: #fff; font-size: 10px; }
.alert-list { display: grid; gap: 7px; }
.alert-row { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.alert-row.critical { border-left: 3px solid var(--red); }
.alert-row.warning { border-left: 3px solid #c58a26; }
.alert-row.info { border-left: 3px solid #72827a; }
.alert-title { font-size: 12px; font-weight: 620; }
.alert-time { margin-top: 3px; color: #79847f; font-size: 10px; }
.empty-state { padding: 15px 12px; border: 1px dashed #cbd4cf; border-radius: 4px; color: #707b75; background: #fafcfb; font-size: 12px; }
.status-label { padding: 4px 8px; border-radius: 4px; font-size: 10px; font-weight: 650; }
.status-disabled { color: #6c4b17; background: var(--amber-soft); }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
table { width: 100%; border-collapse: collapse; text-align: left; white-space: nowrap; }
th, td { padding: 9px 10px; border-bottom: 1px solid #e8ecea; font-size: 11px; }
th { color: #69756f; background: #f7f9f8; font-size: 10px; font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
td { color: #34413b; font-variant-numeric: tabular-nums; }
.empty-cell { padding: 18px 12px; color: #77827d; text-align: center; }
.disabled-action { padding: 4px 7px; border: 1px solid #dfd5c2; border-radius: 4px; color: #846b40; background: #f8f4eb; font-size: 10px; }
.account-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.account-field { padding: 11px 12px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.account-field span { display: block; color: #758079; font-size: 10px; }
.account-field strong { display: block; overflow-wrap: anywhere; margin-top: 5px; font-size: 13px; font-weight: 620; }
.inline-form { display: flex; align-items: end; gap: 9px; margin-top: 12px; }
.inline-form label { display: grid; gap: 5px; }
.inline-form input { width: min(100%, 260px); }
.inline-note { color: #758079; font-size: 11px; }
.config-layout { display: grid; grid-template-columns: minmax(190px, .7fr) minmax(320px, 1.3fr); gap: 14px; align-items: start; }
.version-list { display: grid; gap: 7px; }
.version-item { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 4px; background: #fff; cursor: pointer; text-align: left; }
.version-item:hover { border-color: #91b5a3; }
.version-item.selected { border-color: var(--green); box-shadow: inset 3px 0 var(--green); }
.version-load { display: grid; width: 100%; gap: 3px; padding: 0; border: 0; color: inherit; background: transparent; cursor: pointer; text-align: left; }
.version-rollback { margin-top: 8px; padding: 0; border: 0; color: #52625a; background: transparent; cursor: pointer; font-size: 10px; text-decoration: underline; text-underline-offset: 2px; }
.version-rollback:hover { color: var(--green); }
.version-main { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 650; }
.version-meta { margin-top: 4px; color: #78837d; font-size: 10px; }
.config-editor { min-width: 0; padding: 13px; border: 1px solid var(--line); border-radius: 5px; background: #fff; }
.form-grid { display: grid; grid-template-columns: 150px 130px minmax(180px, 1fr); gap: 9px; margin-bottom: 11px; }
.field-block { display: grid; align-content: start; gap: 5px; }
.instrument-field { display: flex; flex-wrap: wrap; align-content: start; gap: 5px 10px; margin: 0; padding: 6px 9px 8px; border: 1px solid #d6ddda; border-radius: 4px; }
.instrument-field legend { padding: 0 4px; color: #59645f; font-size: 10px; font-weight: 600; }
.instrument-field label { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; }
.instrument-field input { width: 14px; min-height: 14px; height: 14px; margin: 0; accent-color: var(--green); }
.config-editor textarea { width: 100%; min-height: 240px; margin-top: 5px; color: #27312d; background: #fbfcfb; }
.editor-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.file-button { position: relative; overflow: hidden; }
.file-button input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.editor-actions select { min-height: 36px; }
.audit-digest { max-width: 210px; overflow: hidden; color: #6b7670; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-overflow: ellipsis; }
.workspace-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 28px; padding-top: 11px; border-top: 1px solid var(--line); color: #77827d; font-size: 10px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 5; max-width: min(360px, calc(100vw - 36px)); padding: 10px 13px; border: 1px solid #ccd7d1; border-radius: 5px; color: #26332d; background: #fff; box-shadow: 0 5px 18px #18241e18; opacity: 0; pointer-events: none; transform: translateY(7px); transition: opacity .16s ease, transform .16s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .instrument-field { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .topbar { height: 52px; gap: 12px; padding: 0 13px; }
  .topbar-state { margin-left: auto; }
  .operator-controls { gap: 7px; margin-left: 0; }
  .operator-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-shell { min-height: calc(100vh - 52px); grid-template-columns: 1fr; }
  .sidebar { min-height: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-heading, .sidebar-foot { display: none; }
  .side-nav { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .nav-item { min-height: 36px; padding: 7px 6px; text-align: center; font-size: 11px; }
  .workspace { padding: 18px 13px 15px; }
  .workspace-heading { align-items: center; margin-bottom: 15px; }
  .workspace-heading h1 { font-size: 20px; }
  .heading-actions { gap: 7px; }
  .muted-text { max-width: 95px; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
  .metric-tile { min-height: 90px; padding: 11px; }
  .metric-value { font-size: 19px; }
  .content-section { margin-top: 17px; padding-top: 14px; }
  .account-summary { grid-template-columns: 1fr 1fr; }
  .config-layout { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: minmax(0, 1fr) minmax(90px, .7fr); }
  .instrument-field { grid-column: 1 / -1; }
  .inline-form { align-items: stretch; flex-direction: column; }
  .inline-form input { width: 100%; }
  .inline-form button { align-self: flex-start; }
  .workspace-footer { flex-direction: column; gap: 4px; }
}
@media (max-width: 390px) {
  .brand { gap: 7px; font-size: 12px; }
  .topbar { gap: 8px; }
  .topbar-state { gap: 6px; font-size: 10px; }
  .button-quiet { min-height: 28px; padding: 3px 6px; }
  .metric-grid { gap: 7px; }
  .metric-label { font-size: 10px; }
  .metric-meta { font-size: 9px; }
  .heading-actions .button { padding: 6px 8px; }
  .login-panel { padding: 21px 17px; }
}

/* 实盘账户与订单均使用等宽字段，避免旧草稿编辑器的固定列宽挤压凭据输入。 */
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#accounts-body td:last-child .button { margin: 3px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
