/* 模态框通用遮罩与容器 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  box-sizing: border-box;
}
#confirmModal {
  z-index: 250;
}
.modal-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px 24px;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-size: 16.5px;
  font-weight: 600;
  margin: 0;
  color: var(--fg-main);
}
.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-body::-webkit-scrollbar {
  width: 6px;
}
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.6);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: #ffffff;
}

/* 可折叠卡片组件 (Accordion Card) */
.accordion-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.accordion-card:hover {
  border-color: var(--border-dark);
}
.accordion-head {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: var(--bg-sub);
  border-bottom: 1px solid transparent;
}
.accordion-card.open .accordion-head {
  border-bottom-color: var(--border);
  background: #ffffff;
}
.accordion-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--fg-main);
  margin: 0;
}
.accordion-desc {
  font-size: 12px;
  color: var(--fg-muted);
  margin: 2px 0 0;
}
.accordion-arrow {
  font-size: 12px;
  color: var(--fg-muted);
  transition: transform 0.2s ease;
}
.accordion-card.open .accordion-arrow {
  transform: rotate(180deg);
}
.accordion-body {
  display: none;
  padding: 16px 18px;
}
.accordion-card.open .accordion-body {
  display: block;
}

/* 高级选项折叠区块 (details) */
details.adv-details {
  background: var(--bg-sub);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
}
details.adv-details summary {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
details.adv-details summary:hover {
  color: var(--brand);
}
details.adv-details[open] summary {
  margin-bottom: 10px;
}

details.adv-box {
  border: 1px dashed var(--border-dark);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.015);
  margin-top: 12px;
}
details.adv-box summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--fg-muted);
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
details.adv-box summary::-webkit-details-marker { display: none; }
details.adv-box summary::before {
  content: '▸';
  font-size: 11px;
  transition: transform 0.15s ease;
}
details.adv-box[open] summary::before { transform: rotate(90deg); }
details.adv-box summary:hover { color: var(--fg-main); }

/* ---- 移动端专属响应式设计 (@media max-width: 768px) ---- */
.mobile-only { display: none !important; }
.desktop-only { display: revert; }
.mobile-sticky-bar { display: none; }

@media (max-width: 768px) {
  .mobile-only { display: revert !important; }
  .desktop-only { display: none !important; }
  .mode-card-group { grid-template-columns: 1fr; }

  body {
    padding-bottom: 74px; /* 为底部浮动操作栏留出空间 */
  }

  main {
    padding: 0 12px;
    margin: 14px auto;
  }

  header {
    padding: 0 14px;
    height: 52px;
  }
  .brand-logo span {
    font-size: 14px;
  }

  .card {
    padding: 16px 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card {
    padding: 12px 14px;
  }
  .stat-val {
    font-size: 17px !important;
  }

  .tabs-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    padding-bottom: 2px;
    gap: 6px;
    scrollbar-width: none;
  }
  .tabs-nav::-webkit-scrollbar {
    display: none;
  }
  .tab-item {
    padding: 8px 14px;
    font-size: 13px;
  }

  input, select, textarea {
    font-size: 16px;
    padding: 10px 12px;
  }

  .row {
    flex-direction: column;
    gap: 8px;
  }

  .modal-overlay {
    padding: 10px;
    align-items: flex-end;
  }
  .modal-box {
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 18px 16px;
    max-height: 90vh;
    overflow-y: auto;
  }
  .modal-foot {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .modal-foot button {
    width: 100%;
    padding: 11px;
  }

  .table-wrap {
    border: none;
    background: transparent;
    overflow-x: visible;
  }
  table.modern-table,
  table.modern-table thead,
  table.modern-table tbody,
  table.modern-table th,
  table.modern-table td,
  table.modern-table tr {
    display: block;
  }
  table.modern-table thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  table.modern-table tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
  }
  table.modern-table td {
    border: none;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
  }
  table.modern-table td:before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: var(--fg-muted);
    text-align: left;
    margin-right: 12px;
    flex-shrink: 0;
  }
  table.modern-table td:last-child {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    justify-content: flex-end;
  }

  .mobile-sticky-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 10px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    z-index: 90;
    gap: 10px;
    align-items: center;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
  }

  #toast-container {
    top: 10px;
    right: 10px;
    left: 10px;
  }
  .toast {
    min-width: unset;
    width: 100%;
  }
}
