/* ==========================================================================
   媒体雷达 MediaRadar — 操作台样式（console.css）
   依赖 site.css 提供的设计令牌与基础组件（按钮/徽标/表单/开关/骨架/空态）。
   布局：左侧固定深色侧栏 + 右侧内容区；<1080px 侧栏变抽屉。
   ========================================================================== */

/* ---------- 1. 外壳 ---------- */

.console-body {
  background: var(--bg);
}

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* 侧栏 */
.sidebar {
  --side-bg: #0b1220;
  --side-bg-soft: #0f1929;
  --side-text: #a8b6cc;
  --side-text-strong: #eef3fb;
  --side-muted: #64748b;
  --side-border: rgba(255, 255, 255, 0.07);
  --side-hover: rgba(255, 255, 255, 0.06);
  --side-active: rgba(79, 141, 255, 0.16);

  box-sizing: border-box;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 248px;
  background: var(--side-bg);
  border-right: 1px solid var(--side-border);
  color: var(--side-text);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 16px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.sidebar-brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  flex: none;
}

.sidebar-brand .brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-brand strong {
  color: var(--side-text-strong);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.005em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand em {
  font-style: normal;
  color: var(--side-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-close {
  display: none;
  color: var(--side-text);
}

.sidebar-close:hover {
  background: var(--side-hover);
  color: var(--side-text-strong);
}

.side-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  overflow-y: auto;
}

.side-label {
  padding: 8px 12px 6px;
  color: var(--side-muted);
  font-size: 10.5px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 11px;
  height: 42px;
  padding: 0 12px;
  border-radius: 9px;
  color: var(--side-text);
  font-size: 13.5px;
  font-weight: 550;
  transition: background 0.16s ease, color 0.16s ease;
}

.side-link svg {
  width: 18px;
  height: 18px;
  flex: none;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.side-link:hover {
  background: var(--side-hover);
  color: var(--side-text-strong);
}

.side-link.is-active {
  background: var(--side-active);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(120, 170, 255, 0.22);
}

.side-link.is-active svg {
  color: #7fb0ff;
  opacity: 1;
}

.side-link .side-badge {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--side-hover);
  color: var(--side-text);
  font-size: 10.5px;
  font-weight: 650;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.side-link.is-active .side-badge {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.side-nav-divider {
  height: 1px;
  margin: 8px 12px;
  background: var(--side-border);
}

/* 侧栏底部 */
.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--side-border);
}

.side-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--side-text);
  font-size: 11.5px;
  line-height: 1.5;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  flex: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.health-dot.is-ok {
  background: #2fbf71;
  box-shadow: 0 0 0 3px rgba(47, 191, 113, 0.18);
}

.health-dot.is-bad {
  background: #f0544f;
  box-shadow: 0 0 0 3px rgba(240, 84, 79, 0.18);
}

.side-version {
  color: var(--side-muted);
  font-size: 11px;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.side-link-sub {
  height: 34px;
  padding: 0 10px;
  font-size: 12.5px;
  color: var(--side-text);
}

.side-link-sub svg {
  width: 15px;
  height: 15px;
}

/* 主区域 */
.app-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  margin-left: 248px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 66px;
  padding: 10px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-toggle {
  display: none;
}

.topbar-titles {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.5;
}

.breadcrumb a:hover {
  color: var(--brand-strong);
}

.breadcrumb .sep {
  color: var(--border-strong);
}

.topbar h1 {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.012em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.mode-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.mode-chip svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mode-chip[data-mode="remote"] {
  border-color: transparent;
  background: var(--warn-soft);
  color: var(--warn);
}

.icon-btn.needs-token {
  background: var(--warn-soft);
  color: var(--warn);
}

/* 视图容器 */
.view-root {
  flex: 1;
  width: 100%;
  max-width: 1460px;
  margin: 0 auto;
  padding: 24px 28px 56px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: view-in 0.22s ease;
}

.view[hidden] {
  display: none;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.view-desc {
  max-width: 760px;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.7;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---------- 2. 卡片 / 面板 ---------- */

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel {
  padding: 18px 20px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.panel-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.005em;
  line-height: 1.4;
}

.panel-head p {
  margin-top: 2px;
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.6;
}

.panel-aside {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.panel-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

/* ---------- 3. 概览 ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 17px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-label {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--stat-soft, var(--brand-soft));
  color: var(--stat-color, var(--brand));
  flex: none;
}

.stat-icon svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-value {
  color: var(--text);
  font-size: 29px;
  font-weight: 750;
  line-height: 1.08;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  margin-left: 3px;
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}

.stat-hint {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.5;
  flex-wrap: wrap;
}

.stat-hint .dot {
  width: 6px;
  height: 6px;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

/* 平台状态 */
.platform-list {
  display: flex;
  flex-direction: column;
}

.platform-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border);
}

.platform-row:last-child {
  border-bottom: 0;
}

.plat-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.plat-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--pcolor, var(--brand));
  flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pcolor, var(--brand)) 16%, transparent);
}

.plat-copy {
  min-width: 0;
}

.plat-name {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.4;
}

.plat-status-text {
  max-width: 320px;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.5;
}

.plat-nums {
  display: flex;
  gap: 12px;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.plat-nums b {
  color: var(--text-2);
  font-weight: 650;
}

.plat-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* 最近任务 */
.run-panel .panel-head {
  margin-bottom: 12px;
}

.run-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 0 8px;
  color: var(--text-3);
  font-size: 13px;
  line-height: 1.7;
}

.run-headline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.run-time {
  color: var(--text-3);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), #5ba0ff);
  transition: width 0.45s ease;
}

.progress-fill[data-tone="failed"] {
  background: var(--danger);
}

.progress-fill[data-tone="warn"] {
  background: var(--warn);
}

.cover.is-fallback .cover-img {
  display: none;
}

.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.run-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0 0;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.meta-item span {
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.4;
}

.meta-item b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.run-log-tail {
  max-height: 122px;
  margin-top: 14px;
  padding: 9px 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.8;
}

.run-log-tail div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-log-tail .log-ok {
  color: var(--ok);
}

.run-log-tail .log-fail {
  color: var(--danger);
}

/* 立即采集 */
.collect-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.group-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.group-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.mini-actions {
  display: flex;
  gap: 2px;
}

.mini-actions button {
  padding: 2px 7px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--text-3);
  font-size: 11.5px;
  transition: color 0.15s ease, background 0.15s ease;
}

.mini-actions button:hover {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.chip-check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.chip-check:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.chip-check input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.chip-check:has(input:focus-visible) {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.chip-check.is-checked {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}

.chip-check .pdot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--pcolor, var(--brand));
  flex: none;
}

.chip-empty {
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.7;
}

.collect-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.collect-row .btn {
  height: 38px;
}

.form-hint {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.6;
}

.form-hint code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ---------- 4. 关键词 ---------- */

.keyword-forms {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.stack-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field-span {
  grid-column: 1 / -1;
}

.form-error {
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- 5. 表格 ---------- */

.table-panel {
  padding-bottom: 6px;
}

.table-wrap {
  margin: 0 -20px;
  padding: 0 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr {
  transition: background 0.12s ease;
}

.data-table tbody tr:hover {
  background: var(--surface-2);
}

.data-table tbody tr.is-open {
  background: var(--brand-soft);
}

.cell-strong {
  color: var(--text);
  font-weight: 600;
}

.cell-muted {
  color: var(--text-3);
  font-size: 12.5px;
}

.cell-nowrap {
  white-space: nowrap;
}

.cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.col-actions {
  width: 1%;
  text-align: right;
}

.row-actions {
  display: inline-flex;
  gap: 4px;
  justify-content: flex-end;
}

.row-actions .btn {
  height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
}

.badge-row {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.table-loading,
.table-empty {
  padding: 30px 12px;
  color: var(--text-3);
  font-size: 13px;
  text-align: center;
  line-height: 1.7;
}

.table-loading .skeleton {
  height: 12px;
}

.switch-inline {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.switch-inline .switch {
  transform: scale(0.9);
  transform-origin: left center;
}

.switch-inline span {
  color: var(--text-3);
  font-size: 11.5px;
}

/* ---------- 6. 线索流 ---------- */

.filter-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
}

.field-inline {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 0 0 auto;
}

.field-inline > span {
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
}

.field-inline .select,
.field-inline .input {
  min-width: 124px;
  height: 34px;
  border-radius: 8px;
  font-size: 13px;
}

.field-grow {
  flex: 1 1 220px;
  min-width: 180px;
}

.filter-bar .checkbox {
  height: 34px;
}

.filter-bar .btn {
  align-self: end;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-card {
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.item-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.item-card.is-hidden {
  opacity: 0.66;
}

.item-cover {
  position: relative;
  width: 100%;
  height: 78px;
  border-radius: 8px;
  overflow: hidden;
  background: #0b1220;
}

.item-cover .cover-fallback svg {
  width: 26px;
  height: 26px;
}

.item-cover .cover-fallback em {
  font-size: 10px;
  letter-spacing: 0.08em;
}

.item-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.item-title-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.item-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  line-height: 1.5;
  letter-spacing: -0.005em;
}

.item-title a:hover {
  color: var(--brand-strong);
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.item-tags {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.item-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  flex: none;
}

.item-links {
  display: flex;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-3);
}

.item-links a:hover {
  color: var(--brand-strong);
}

.pagination-console {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 2px;
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.pager-buttons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- 7. 任务 ---------- */

.log-panel {
  border-left: 3px solid var(--brand);
}

.log-panel .panel-head {
  margin-bottom: 12px;
}

.auto-refresh-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-3);
  font-size: 12px;
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: pulse-dot 1.4s ease infinite;
}

.badge .pulse-dot {
  width: 6px;
  height: 6px;
  background: currentColor;
}

@keyframes pulse-dot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(18, 128, 92, 0.4);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(18, 128, 92, 0);
  }
}

.logs-table {
  min-width: 880px;
}

.log-message {
  max-width: 340px;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.6;
  word-break: break-word;
}

/* ---------- 8. 设置 ---------- */

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.settings-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
}

.settings-card .panel-head {
  margin-bottom: 0;
}

.span-2 {
  grid-column: 1 / -1;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.code-block {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 13px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.75;
}

.code-block code {
  flex: 1;
  min-width: 0;
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-all;
}

.copy-btn {
  flex: none;
  height: 26px;
  padding: 0 9px;
  border-radius: 6px;
  font-size: 11.5px;
}

.mode-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-option {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.7;
}

.mode-option strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text);
  font-size: 13px;
}

.mode-option.is-current {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.mode-option .badge {
  margin-top: 7px;
}

.token-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-value {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 11.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.states-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.state-row {
  display: grid;
  grid-template-columns: minmax(170px, 0.9fr) minmax(0, 1.5fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.state-main {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  min-width: 0;
}

.state-name {
  color: var(--text);
  font-size: 13.5px;
  font-weight: 650;
}

.state-meta {
  min-width: 0;
  color: var(--text-3);
  font-size: 11.5px;
  line-height: 1.7;
}

.state-command {
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.state-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.state-actions .btn {
  height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
}

.file-label {
  position: relative;
  display: inline-flex;
  overflow: hidden;
}

.file-label input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  opacity: 0;
  cursor: pointer;
}

.digest-preview {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.digest-summary {
  display: flex;
  align-items: baseline;
  gap: 22px;
  flex-wrap: wrap;
  color: var(--text-3);
  font-size: 12.5px;
}

.digest-summary b {
  margin-right: 4px;
  color: var(--text);
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.digest-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.digest-group-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
}

.digest-list {
  display: flex;
  flex-direction: column;
  max-height: 300px;
  overflow: auto;
  border-top: 1px solid var(--border);
}

.digest-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--border);
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.6;
}

.digest-item:last-child {
  border-bottom: 0;
}

.digest-item .digest-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.digest-item a:hover {
  color: var(--brand-strong);
}

.link {
  color: var(--brand-strong);
  font-weight: 600;
}

.link:hover {
  text-decoration: underline;
}

.section-divider {
  height: 1px;
  margin: 2px 0;
  background: var(--border);
}

/* ---------- 9. Toast ---------- */

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: max-content;
  max-width: min(390px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  animation: toast-in 0.2s ease;
}

.toast > svg {
  width: 16px;
  height: 16px;
  flex: none;
  margin-top: 1px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toast.is-ok > svg {
  color: var(--ok);
}

.toast.is-error > svg {
  color: var(--danger);
}

.toast.is-info > svg {
  color: var(--brand);
}

.toast .toast-close {
  margin-left: auto;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  font-size: 15px;
  line-height: 1;
}

.toast.is-leaving {
  animation: toast-out 0.18s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateX(14px);
  }
}

/* ---------- 10. 弹层 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(9, 15, 27, 0.55);
  animation: modal-fade 0.16s ease;
}

.modal[hidden] {
  display: none;
}

.modal-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  max-height: min(88vh, 760px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: modal-rise 0.18s ease;
}

.modal-sm {
  max-width: 430px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 20px;
  overflow: auto;
}

.modal-desc {
  color: var(--text-3);
  font-size: 12.5px;
  line-height: 1.75;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 13px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-foot .danger-note {
  margin-right: auto;
  color: var(--danger);
  font-size: 12px;
}

@keyframes modal-fade {
  from {
    opacity: 0;
  }
}

@keyframes modal-rise {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
}

/* 骨架辅助 */
.sk-line {
  height: 12px;
  border-radius: 6px;
}

.sk-title {
  height: 16px;
  border-radius: 6px;
}

.sk-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 2px;
}

.sk-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

/* 错误状态容器（复用 site.css 的 .error-state） */
.inline-error {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- 11. 响应式 ---------- */

.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(9, 15, 27, 0.5);
}

@media (max-width: 1080px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-close {
    display: inline-flex;
    color: var(--side-text);
  }

  body.nav-open .sidebar {
    transform: none;
  }

  body.nav-open .sidebar-scrim {
    display: block;
  }

  .app-main {
    margin-left: 0;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .keyword-forms {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .span-2 {
    grid-column: auto;
  }

  .state-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .state-actions {
    justify-content: flex-start;
  }

  .view-root {
    padding: 20px 18px 48px;
  }

  .topbar {
    padding: 10px 18px;
  }
}

@media (max-width: 720px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 14px;
    gap: 7px;
  }

  .stat-value {
    font-size: 24px;
  }

  .stat-label {
    font-size: 11.5px;
  }

  .stat-icon {
    width: 28px;
    height: 28px;
  }

  .collect-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid,
  .form-grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .mode-options {
    grid-template-columns: minmax(0, 1fr);
  }

  .item-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .item-cover {
    height: 64px;
  }

  .item-side {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .view-head {
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .mode-chip {
    display: none;
  }

  .field-grow {
    flex-basis: 100%;
  }

  .panel {
    padding: 14px 16px;
  }

  .table-wrap {
    margin: 0 -16px;
    padding: 0 16px;
  }

  .toast-stack {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
  }

  .modal {
    padding: 12px;
  }

  .run-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-titles {
    max-width: 52vw;
  }
}

/* ---------- 12. 动效偏好 ---------- */

@media (prefers-reduced-motion: reduce) {
  .view,
  .toast,
  .modal,
  .modal-card {
    animation: none;
  }
}

/* ===== 扫码登录弹窗 ===== */
.login-qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid rgba(127, 127, 127, 0.22);
  background: rgba(127, 127, 127, 0.07);
  overflow: hidden;
}

.login-qr-box img {
  display: none;
  max-width: 100%;
  max-height: 430px;
  border-radius: 8px;
  background: #fff;
}

.login-qr-box img.is-ready {
  display: block;
}

.login-qr-box img.is-ready + .login-qr-placeholder {
  display: none;
}

.login-qr-placeholder {
  color: rgba(127, 127, 127, 0.9);
  font-size: 13px;
}

#loginQrStatus.is-error {
  color: #e8453c;
}

.login-qr-box img.is-ready {
  display: block;
  width: min(100%, 340px);
  height: auto;
  image-rendering: pixelated;
}
