/* ── 变量 & 重置 ─────────────────────────────────────────────── */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242736;
  --border: #2e3246;
  --accent: #5b8def;
  --accent-hover: #4a78de;
  --success: #2dd4a0;
  --warn: #f5a623;
  --danger: #f26464;
  --text: #e2e6f3;
  --text-muted: #7b82a0;
  --radius: 8px;
  --sidebar-w: 200px;
  --transition: 0.18s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  height: 100vh;
  overflow: hidden;
}

/* ── 登录页 ──────────────────────────────────────────────────── */
#login-page {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 360px;
}
.login-card h1 {
  font-size: 20px; font-weight: 700; margin-bottom: 8px;
  color: var(--text);
}
.login-card p { color: var(--text-muted); margin-bottom: 28px; font-size: 13px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: 14px;
  outline: none; transition: border-color var(--transition);
}
.form-group input:focus { border-color: var(--accent); }
.login-err { color: var(--danger); font-size: 12px; margin-bottom: 12px; min-height: 16px; }

/* ── 布局 ───────────────────────────────────────────────────── */
#app {
  display: flex; height: 100vh;
}
#sidebar {
  width: var(--sidebar-w); background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 20px 16px 16px;
  font-size: 15px; font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--border);
}
.sidebar-logo span { color: var(--accent); }
nav { flex: 1; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius);
  cursor: pointer; color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
  font-size: 13px; font-weight: 500;
  user-select: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(91,141,239,.15); color: var(--accent); }
.nav-icon { font-size: 16px; }
.sidebar-footer {
  padding: 12px 8px; border-top: 1px solid var(--border);
}
.ws-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-muted); padding: 4px 12px;
}
.ws-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); flex-shrink: 0;
}
.ws-dot.connected { background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse {
  0%,100% { opacity: 1; } 50% { opacity: .4; }
}
#main-content {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.page-container {
  flex: 1; overflow-y: auto; padding: 24px;
}

/* ── 通用组件 ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: none; transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-danger { background: rgba(242,100,100,.15); color: var(--danger); border: 1px solid rgba(242,100,100,.3); }
.btn-danger:hover:not(:disabled) { background: rgba(242,100,100,.25); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(45,212,160,.15); color: var(--success); }
.badge-warn    { background: rgba(245,166,35,.15);  color: var(--warn); }
.badge-danger  { background: rgba(242,100,100,.15); color: var(--danger); }
.badge-info    { background: rgba(91,141,239,.15);  color: var(--accent); }
.badge-muted   { background: var(--surface2); color: var(--text-muted); }

/* ── 监控页 ──────────────────────────────────────────────────── */
#page-monitor .monitor-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.monitor-stats { display: flex; align-items: center; gap: 16px; }
.stat-chip {
  font-size: 12px; color: var(--text-muted);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
}
.stat-chip strong { color: var(--text); }
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: transform var(--transition), border-color var(--transition);
}
.product-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.product-card.new-flash {
  animation: card-flash 1.5s ease;
}
@keyframes card-flash {
  0%,100% { border-color: var(--border); box-shadow: none; }
  30% { border-color: var(--success); box-shadow: 0 0 12px rgba(45,212,160,.3); }
}
.card-media { position: relative; width: 100%; }
.card-img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  background: var(--surface2); display: block;
}
.card-img-placeholder {
  width: 100%; aspect-ratio: 1;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: var(--text-muted);
}
.card-body { padding: 10px 12px; }
.card-product-name {
  font-size: 12px; color: var(--text); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 6px; min-height: 2.8em;
}
.card-product-price {
  font-size: 13px; font-weight: 600;
  color: var(--accent);
  margin-bottom: 10px;
  line-height: 1.35;
  word-break: break-all;
}
/* Grid 双列：避免 flex 在窄卡片/最小宽度下把第二颗挤到下一行 */
#page-monitor .product-card .card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
  width: 100%;
  box-sizing: border-box;
}
#page-monitor .product-card .card-actions .card-action-btn {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  justify-content: center;
  text-align: center;
  padding: 4px 4px;
  font-size: 11px;
  line-height: 1.25;
}
/* <a> 默认紫色下划线会盖过 .btn，需与按钮一致 */
.card-actions a.btn.btn-primary,
.card-actions a.btn.btn-primary:visited {
  color: #fff;
  text-decoration: none;
}
.card-actions a.btn.btn-primary:hover {
  color: #fff;
}
.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  text-decoration: none;
  box-sizing: border-box;
}
.btn-secondary:hover:not(.btn-disabled) {
  background: var(--border);
  color: var(--text);
}
.btn-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 0; color: var(--text-muted); gap: 12px;
}
.empty-state .icon { font-size: 40px; }

/* ── 账号管理页 ──────────────────────────────────────────────── */
.accounts-table-wrap { overflow-x: auto; }
.accounts-main-table tbody tr.account-session-row td {
  padding: 0 14px 14px;
  background: rgba(0, 0, 0, 0.18);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.accounts-main-table tbody tr.account-session-row:hover { background: transparent; }
.account-session-panel { padding-top: 4px; }
.account-session-summary {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.account-session-summary strong { color: var(--accent); font-size: 14px; }
.account-session-subtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.account-session-subtable thead th {
  padding: 6px 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.account-session-subtable tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.account-session-subtable tbody tr:last-child td { border-bottom: none; }
table {
  width: 100%; border-collapse: collapse;
}
thead th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  font-weight: 600;
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody td { padding: 12px 14px; font-size: 13px; }
tbody tr.active-row { background: rgba(91,141,239,.07); }

.add-account-section {
  margin-top: 24px; padding: 20px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.add-account-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; margin-bottom: 0; }

/* ── 下单结果页 ──────────────────────────────────────────────── */
.orders-list { display: flex; flex-direction: column; gap: 8px; }
.order-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 16px;
}
.order-row.status-running { border-left: 3px solid var(--accent); }
.order-row.status-success { border-left: 3px solid var(--success); }
.order-row.status-failed  { border-left: 3px solid var(--danger); }
.order-row.status-pending { border-left: 3px solid var(--text-muted); }
.order-info { flex: 1; }
.order-name { font-size: 13px; font-weight: 500; color: var(--text); }
.order-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.order-msg  { font-size: 12px; color: var(--text-muted); margin-top: 4px; max-width: 400px; }
.order-time { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.spin { display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 提示通知 ────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 9999;
}
.toast {
  padding: 12px 16px; border-radius: var(--radius);
  font-size: 13px; color: #fff;
  background: var(--surface2); border: 1px solid var(--border);
  min-width: 240px; max-width: 360px;
  animation: slide-in .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }
@keyframes slide-in { from { transform: translateX(20px); opacity:0; } to { transform: none; opacity:1; } }

/* ── 弹窗 ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; width: 400px;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
}
.modal-box h3 { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── 滚动条 ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
