/* mobile-first：默认手机；min-width:768px 为桌面 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0.75rem;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  color: #1a1a1a;
  background: #eef1f5;
}

.shell {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 1rem;
}

.page-title {
  font-size: 1.35rem;
  margin: 0 0 0.25rem;
  font-weight: 700;
}

.page-sub {
  margin: 0;
  font-size: 0.95rem;
  color: #5f6368;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-title {
  font-size: 1.1rem;
  margin: 0 0 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #e8eaed;
  font-weight: 600;
}

.flash {
  padding: 0.85rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.flash.ok {
  background: #e6f4ea;
  color: #137333;
}

.flash.err {
  background: #fce8e6;
  color: #b3261e;
}

.collapsible-stack-card {
  padding-top: 0.65rem;
}

.collapse-panel {
  border-bottom: 1px solid #e8eaed;
}

.collapse-panel:last-child {
  border-bottom: none;
}

.collapse-panel--log {
  margin-top: 0.35rem;
}

.alert-params-card {
  margin-bottom: 1.5rem;
}

.alert-params-lead {
  margin-bottom: 1rem;
}

.alert-params-subtitle {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
  font-weight: 600;
  color: #3c4043;
}

.alert-params-subtitle:first-of-type {
  margin-top: 0;
}

.alert-params-form .field input[type="text"] {
  width: 100%;
  max-width: 12rem;
}

.collapse-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  cursor: pointer;
  list-style: none;
  padding: 0.75rem 0.15rem;
  font-weight: 600;
  font-size: 1.05rem;
  color: #1a1a1a;
}

.collapse-summary::-webkit-details-marker {
  display: none;
}

.collapse-summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.45rem;
  font-weight: 400;
  color: #5f6368;
  transition: transform 0.15s ease;
}

details[open] > .collapse-summary::before {
  transform: rotate(90deg);
}

.collapse-summary--small {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.55rem 0.15rem;
}

.collapse-summary__title {
  flex: 1 1 auto;
}

.collapse-summary__hint {
  font-size: 0.82rem;
  font-weight: 400;
  color: #80868b;
}

.collapse-body {
  padding: 0 0 0.85rem 1.15rem;
}

.collapse-log-hint {
  margin-top: 0;
}

.log-snippet {
  margin: 0.5rem 0 0;
  padding: 0.65rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  background: #f1f3f4;
  border-radius: 8px;
  max-height: min(42vh, 22rem);
  overflow: auto;
  border: 1px solid #e8eaed;
}

.alert-services-lead {
  margin: 0 0 0.85rem;
  font-size: 0.88rem;
  color: #5f6368;
}

.systemd-meta {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: #5f6368;
}

.systemd-warn {
  color: #b3261e;
  font-weight: 600;
}

.hint {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: #5f6368;
}

.empty-tip {
  margin: 0;
  color: #5f6368;
  font-size: 1rem;
}

/* 顶部状态 */
.status-card .status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 1rem;
  margin: 0 0 1rem;
}

.status-item {
  margin: 0;
}

.status-item dt {
  font-size: 0.85rem;
  color: #5f6368;
  margin: 0 0 0.15rem;
  font-weight: 500;
}

.status-item dd {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.status-item--wide {
  grid-column: 1 / -1;
}

/* 手机：显示卡片列表；隐藏桌面表格 */
.desktop-only {
  display: none !important;
}

.mobile-only {
  display: block;
}

/* 移动端：紧凑持仓列表（每只约 72–96px 高，弱化买入信息） */
.positions-compact {
  display: flex;
  flex-direction: column;
  border: 1px solid #e8eaed;
  border-radius: 8px;
  overflow: hidden;
  background: #f8f9fa;
}

.pos-row {
  padding: 0.45rem 0.6rem 0.5rem;
  border-bottom: 1px solid #e8eaed;
  min-height: 72px;
  background: #fff;
}

.pos-row:last-child {
  border-bottom: none;
}

.pos-row__line1 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.pos-row__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.45rem;
  min-width: 0;
  flex: 1;
}

.pos-row__code,
.pos-row__name {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.25;
  color: #202124;
}

.pos-row__meta {
  margin: 0.2rem 0 0;
  font-size: 0.875rem;
  color: #80868b;
  line-height: 1.35;
}

.pos-row__meta--muted {
  color: #9aa0a6;
  font-style: normal;
}

.pos-row__remark {
  margin: 0.15rem 0 0;
  font-size: 0.8125rem;
  color: #5f6368;
  line-height: 1.35;
}

.pos-row__del-form {
  margin: 0;
  flex-shrink: 0;
}

.pos-row__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  flex-shrink: 0;
}

.pos-row__inline-form {
  margin: 0;
}

.sell-status {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: #5f6368;
}

.sell-status__reset {
  color: #80868b;
  font-size: 0.78rem;
}

.sell-status-cell {
  min-width: 9.5rem;
  max-width: 14rem;
}

.table-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
}

.table-actions__form {
  margin: 0;
}

.btn-delete-compact {
  min-height: 32px;
  height: 32px;
  padding: 0 0.55rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

/* 添加持仓：手机端两列，极窄屏单列 */
.form-add.form-stack {
  gap: 0.65rem;
}

.form-add__row--2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.65rem;
}

.form-add .field input {
  min-height: 40px;
  padding: 0.4rem 0.55rem;
}

@media (max-width: 380px) {
  .form-add__row--2 {
    grid-template-columns: 1fr;
  }
}

/* 卡片列表（持仓 / 候选） */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.item-card {
  border: 1px solid #e8eaed;
  border-radius: 10px;
  padding: 0.85rem 1rem 1rem;
  background: #fafbfc;
}

.item-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e8eaed;
}

.item-card__code {
  font-weight: 700;
  font-size: 1.05rem;
}

.item-card__name {
  font-size: 1rem;
  color: #3c4043;
}

.kv {
  margin: 0;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid #f1f3f4;
  font-size: 0.98rem;
}

.kv-row:last-child {
  border-bottom: none;
}

.kv-row dt {
  margin: 0;
  color: #5f6368;
  flex: 0 0 auto;
}

.kv-row dd {
  margin: 0;
  text-align: right;
  word-break: break-word;
}

.kv-row--block {
  flex-direction: column;
  align-items: stretch;
  gap: 0.25rem;
}

.kv-row--block dd {
  text-align: left;
}

.promote-box {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px dashed #dadce0;
}

.promote-title {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #3c4043;
}

/* 表单：手机全宽竖排 */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.field label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #3c4043;
}

.field input {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.65rem;
  font-size: 16px;
  border: 1px solid #dadce0;
  border-radius: 8px;
}

.field input:focus {
  outline: 2px solid #1a73e8;
  outline-offset: 1px;
}

.field--checkbox {
  margin-top: 0.35rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: 600;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.form-actions {
  margin-top: 0.25rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: #1a73e8;
  border-color: #1557b0;
  color: #fff;
}

.btn-primary:active {
  background: #1557b0;
}

.btn-danger {
  background: #c5221f;
  border-color: #a50e0e;
  color: #fff;
}

.btn-danger:active {
  background: #a50e0e;
}

.btn-secondary {
  background: #fff;
  border-color: #dadce0;
  color: #1a73e8;
}

.btn-secondary:active {
  background: #f1f3f4;
}

.btn-sm {
  min-height: 36px;
  font-size: 0.875rem;
  padding: 0.35rem 0.65rem;
}

/* 桌面：居中 + 表格 */
@media (min-width: 768px) {
  body {
    padding: 1.25rem;
    font-size: 15px;
  }

  .shell {
    max-width: 1200px;
  }

  .page-title {
    font-size: 1.5rem;
  }

  .card {
    padding: 1.25rem 1.35rem;
  }

  .mobile-only {
    display: none !important;
  }

  .desktop-only {
    display: block !important;
  }

  .table-wrap.desktop-only {
    overflow-x: auto;
  }

  .data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
  }

  .data-table th,
  .data-table td {
    text-align: left;
    padding: 0.55rem 0.45rem;
    border-bottom: 1px solid #eee;
    vertical-align: top;
  }

  .data-table th {
    font-weight: 600;
    color: #444;
    white-space: nowrap;
  }

  .form-inline-desktop {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    align-items: flex-end;
    max-width: 28rem;
  }

  .form-inline-desktop .field-inline {
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    color: #555;
  }

  .form-inline-desktop .label-text {
    margin-bottom: 0.15rem;
  }

  .form-inline-desktop input {
    min-width: 5rem;
    min-height: 36px;
    padding: 0.3rem 0.45rem;
    font-size: 0.875rem;
    border: 1px solid #ccc;
    border-radius: 4px;
  }

  .status-card .status-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .status-item--wide {
    grid-column: auto;
  }

  .status-card .form-actions {
    max-width: 14rem;
  }

  .status-card .btn-block {
    width: auto;
    min-width: 10rem;
  }

  .form-stack .form-actions .btn-block {
    width: auto;
    min-width: 12rem;
  }

  /* 桌面：添加持仓恢复单列 */
  .form-add .form-add__row--2 {
    grid-template-columns: 1fr;
    max-width: 22rem;
  }

  .form-add .field input {
    min-height: 44px;
  }
}

.meta.small {
  font-size: 0.8rem;
  margin-top: 1rem;
}

.wrap {
  word-break: break-word;
}

.hint {
  color: #5f6368;
  font-size: 0.9rem;
  margin: 0 0 1rem;
}

form.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 28rem;
}

.field label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.field .explain {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: #5f6368;
}

.field input[type="number"] {
  width: 100%;
  max-width: 12rem;
}

button.primary {
  align-self: flex-start;
  margin-top: 0.25rem;
}
