/**
 * 管理后台全局样式
 * - :root 设计令牌（深色主题色板）
 * - .app-shell / .sidebar 布局与导航
 * - .card / .btn / .table 通用组件
 * - 各功能页专用区块：download-*、wm-*、dedup-* 等
 */
:root {
  --bg: #0b0e14;
  --bg2: #0f1319;
  --panel: #141820;
  --panel2: #1a2030;
  --border: #252b38;
  --text: #e6eaf2;
  --muted: #8b95a8;
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.12);
  --purple: #7c5cff;
  --red: #ff4d6d;
  --green: #22c55e;
  --orange: #f59e0b;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif; font-size: 14px; }
a { color: var(--cyan); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.login-body { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 50% 0%, #152030, var(--bg)); }
.login-card { width: min(400px, 92vw); background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 36px 32px; }
.login-card .brand-title { color: var(--cyan); font-size: 22px; font-weight: 700; text-align: center; }
.login-card .brand-sub { color: var(--muted); font-size: 11px; text-align: center; letter-spacing: .12em; margin-top: 6px; margin-bottom: 24px; }

.app-shell { display: grid; grid-template-columns: 168px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 10px; }
.brand-title { color: var(--cyan); font-size: 17px; font-weight: 700; padding: 4px 8px 16px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { padding: 10px 12px; border-radius: 6px; color: var(--muted); font-size: 13px; transition: .15s; }
.nav a:hover { color: var(--text); background: rgba(255,255,255,.04); }
.nav a.active { color: #fff; background: linear-gradient(90deg, rgba(0,229,255,.25), rgba(0,229,255,.08)); border-left: 3px solid var(--cyan); padding-left: 9px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; font-size: 11px; color: #5a6478; line-height: 1.5; }

.main-wrap { display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--bg2); }
.topbar-left { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.badge-customer { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(0,229,255,.3); padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 12px; color: var(--muted); }
.btn-exit { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 6px 14px; border-radius: 6px; cursor: pointer; }
.btn-exit:hover { border-color: var(--muted); }
.main { padding: 16px 20px; flex: 1; overflow: auto; }

.page-title { color: var(--cyan); font-size: 16px; font-weight: 600; margin: 0 0 4px; }
.page-sub { color: var(--muted); font-size: 12px; margin: 0 0 16px; }

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--text); }
.card-sub { font-size: 12px; color: var(--muted); margin: -8px 0 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.split-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; min-height: 420px; }
.split-panel-task { align-items: start; }
.split-panel-task .task-list-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.split-panel-task .task-list-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 420px;
}
.split-panel-task .task-list-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel);
  box-shadow: 0 1px 0 var(--border);
}
.task-list-toolbar { margin-bottom: 8px; }
.task-select-all-label { font-size: 12px; color: var(--muted); cursor: pointer; user-select: none; }
.task-select-all-label input { margin-right: 4px; vertical-align: middle; }

.device-log-split {
  grid-template-columns: minmax(220px, 34%) 1fr;
  align-items: stretch;
  min-height: 0;
  min-height: 200px;
}
.device-log-split .device-select-col,
.device-log-split .ec-log-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.device-log-split .ec-log-col .ec-log-panel-inline {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 0;
}
.device-log-split .ec-log-col .ec-log-pre {
  flex: 1;
  min-height: 160px;
  max-height: min(320px, 36vh);
  margin: 0;
}

.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); outline: none;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: rgba(0,229,255,.4); }
.form-row textarea { min-height: 100px; resize: vertical; }

.btn { border: 0; border-radius: 6px; padding: 8px 16px; cursor: pointer; font-weight: 500; font-size: 13px; }
.btn-primary { background: linear-gradient(135deg, #00c8ff, #0077ff); color: #fff; }
.btn-purple { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: #fff; }
.btn-cyan { background: var(--cyan); color: #000; font-weight: 600; }
.btn-secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--border); padding: 8px 6px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr:hover td { background: rgba(255,255,255,.02); }

.empty { color: var(--muted); text-align: center; padding: 32px; font-size: 13px; }
.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.alert-info { background: rgba(0,229,255,.08); border: 1px solid rgba(0,229,255,.2); color: #a5f3fc; }
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.25); color: #86efac; }
.alert-error { background: rgba(255,77,109,.1); border: 1px solid rgba(255,77,109,.25); color: #fecaca; }
.alert-warn { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.25); color: #fcd34d; }

.log-box { background: #080a0f; border: 1px solid var(--border); border-radius: 6px; padding: 10px; min-height: 120px; max-height: 280px; overflow: auto; font-family: ui-monospace, monospace; font-size: 11px; white-space: pre-wrap; color: #9aa4b2; }

/* 抖音脚本页 EC 日志：固定高度、内部滚动，不撑破布局 */
.ec-log-panel { margin-top: 10px; }
.ec-log-pre {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  min-height: 140px;
  max-height: min(300px, 38vh);
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #080a0f;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, "Menlo", "Consolas", monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  color: #9aa4b2;
}

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { padding: 8px 16px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; }
.tab.active { color: var(--cyan); border-bottom-color: var(--cyan); }
.device-check-item { display: block; margin: 6px 0; font-size: 13px; }
.device-check-item .muted { color: var(--muted); font-size: 12px; }
.status-badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; text-transform: lowercase; }
.status-pending { background: rgba(245,158,11,.15); color: #f59e0b; }
.status-running { background: rgba(0,229,255,.12); color: var(--cyan); }
.status-done { background: rgba(34,197,94,.15); color: #22c55e; }
.status-stopped { background: rgba(0,229,255,.12); color: var(--cyan); }
.status-failed { background: rgba(239,68,68,.15); color: #ef4444; }
.form-row select, .form-row textarea { width: 100%; background: var(--input-bg, #12151c); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 8px 10px; font-size: 13px; }
.form-row textarea { resize: vertical; min-height: 72px; font-family: inherit; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.metric-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; text-align: center; }
.metric-val { font-size: 22px; font-weight: 700; color: var(--cyan); }
.metric-label { font-size: 11px; color: var(--muted); margin-top: 4px; }

.category-sections { display: flex; flex-direction: column; gap: 20px; }
.category-section-head { margin-bottom: 10px; }
.category-section-title { font-size: 15px; font-weight: 600; color: var(--cyan); margin: 0 0 4px; }
.category-section-desc { font-size: 12px; color: var(--muted); margin: 0; }
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.category-grid-inner { margin-bottom: 4px; }
.category-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 14px 8px; text-align: center; cursor: pointer; transition: .15s; }
.category-card:hover { border-color: rgba(0,229,255,.4); background: rgba(0,229,255,.05); }
.category-icon { font-size: 22px; margin-bottom: 6px; }
.category-name { font-size: 12px; font-weight: 500; }
.category-count { font-size: 11px; color: var(--muted); margin-top: 4px; }

.material-list { display: flex; flex-direction: column; gap: 0; }
.material-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.material-title { flex: 1; line-height: 1.5; }
.material-tag {
  flex-shrink: 0; font-size: 11px; padding: 2px 8px; border-radius: 4px;
  background: rgba(0,229,255,.12); color: var(--cyan); border: 1px solid rgba(0,229,255,.25);
}

.page-banner {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: #86efac;
}
.page-banner.banner-error {
  background: rgba(255, 77, 109, 0.12);
  border-color: rgba(255, 77, 109, 0.35);
  color: #ffb3c1;
}
.page-banner.banner-info {
  background: rgba(0, 229, 255, 0.08);
  border-color: rgba(0, 229, 255, 0.2);
  color: #a5f3fc;
}
.page-banner a { color: #7dd3fc; text-decoration: underline; }
.parse-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel2);
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.parse-input:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(0,229,255,.12); }
.parse-status { margin: 8px 0 0; font-size: 12px; color: #86efac; }
.parse-status.error { color: #ef4444; }
.parse-status.info { color: #a5f3fc; }
.download-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; position: relative; }
.download-card .thumb { width: 100%; aspect-ratio: 3/4; background: #1a2030; object-fit: cover; }
.download-card .info { padding: 8px; }
.download-card .title { font-size: 12px; line-height: 1.4; height: 34px; overflow: hidden; }
.download-card .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.download-card .actions { display: flex; gap: 4px; padding: 0 8px 8px; }
.platform-tag { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); background: #ff2442; color: #fff; font-size: 10px; padding: 2px 8px; border-radius: 4px; }
.card-check { position: absolute; top: 8px; left: 8px; }

.upload-zone { border: 2px dashed var(--border); border-radius: 10px; padding: 40px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; }
.upload-zone:hover { border-color: rgba(0,229,255,.4); color: var(--text); }
.upload-zone .icon { font-size: 32px; margin-bottom: 8px; }

.wm-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.wm-result-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.wm-result-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }

.iframe-wrap { height: calc(100vh - 120px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; }
.iframe-wrap iframe,
.iframe-wrap webview { width: 100%; height: 100%; border: 0; display: inline-flex; }
.download-input-row { display: flex; gap: 8px; align-items: stretch; }
.download-input-row input { flex: 1; }
.download-input-row .btn { white-space: nowrap; padding: 8px 20px; }
.download-preview { display: flex; gap: 16px; align-items: flex-start; }
.download-cover { width: 120px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: var(--panel2); flex-shrink: 0; }
.download-meta { flex: 1; min-width: 0; }
.download-title { margin: 0 0 8px; font-size: 15px; line-height: 1.5; word-break: break-word; }
.download-source { margin: 0; font-size: 12px; color: var(--muted); word-break: break-all; }
.download-actions { display: flex; flex-direction: column; gap: 10px; }
.download-action-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; background: var(--panel2); border-radius: 8px; border: 1px solid var(--border); }
.download-action-label { font-size: 13px; color: var(--text); }
.download-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.download-step { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.download-step span { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--cyan-dim); color: var(--cyan); font-size: 11px; font-weight: 600; margin-right: 6px; }
@media (max-width: 900px) {
  .device-log-split { grid-template-columns: 1fr; }
  .device-log-split .ec-log-col .ec-log-pre { max-height: 240px; }
  .download-steps { grid-template-columns: 1fr; }
  .download-action-row { flex-direction: column; align-items: flex-start; }
}

.magiceraser-steps { margin-bottom: 0; }
.wm-tabs { margin-bottom: 14px; }
.wm-tabs .wm-tab.active { background: linear-gradient(135deg, #00c8ff, #0077ff); color: #fff; border-color: transparent; }
.wm-panel { margin-bottom: 14px; }
.wm-canvas-wrap { position: relative; width: 100%; min-height: 240px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.wm-canvas-wrap canvas { display: block; max-width: 100%; }
.wm-mask-layer { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); opacity: 0.55; cursor: crosshair; touch-action: none; }
.wm-result { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.wm-result-img { width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; background: #000; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.pagination { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }

.chart-box { height: 220px; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }

#desktop-badge { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: rgba(0,229,255,.1); color: var(--cyan); }

.res-help { margin-bottom: 12px; }
.res-steps { margin: 0 0 10px 18px; color: var(--muted); font-size: 13px; line-height: 1.7; }
.res-warn { margin: 0; color: #f59e0b; font-size: 12px; }
.res-toolbar { align-items: center; }
.res-save-path { font-size: 12px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-type-select { min-width: 120px; background: var(--panel2); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.res-table td, .res-table th { vertical-align: middle; }
.res-desc-input { width: 100%; min-width: 100px; background: var(--panel2); border: 1px solid var(--border); color: var(--text); border-radius: 4px; padding: 4px 6px; font-size: 12px; }
.res-path { font-size: 11px; color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-status.ok { color: #22c55e; }
.res-status.err { color: #ef4444; }
.res-actions { white-space: nowrap; }
.res-link-parse { margin-top: 12px; }
.res-modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 9999; align-items: center; justify-content: center; }
.res-modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; width: 360px; max-width: 90vw; }

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .split-panel, .grid-2, .grid-3, .metric-grid { grid-template-columns: 1fr; }
  .device-log-split { grid-template-columns: 1fr; }
}

/* 全局操作提示 Toast */
.toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  color: #fff;
  background: rgba(20, 24, 32, 0.96);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { border-color: rgba(34, 197, 94, 0.45); }
.toast-error { border-color: rgba(255, 77, 109, 0.55); }
.toast-info { border-color: rgba(0, 229, 255, 0.35); }
.toast-warn { border-color: rgba(245, 158, 11, 0.45); }
