/* 自动化活动控制 - 统一设计系统 */
:root {
  /* 布局（可覆盖以适配新模块） */
  --sidebar-width: 240px;
  --content-max-width: 1280px;
  /* 色彩与圆角 */
  --bg-page: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-hint: #94a3b8;
  --primary: #0f766e;
  --primary-hover: #0d9488;
  --primary-light: #ccfbf1;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fee2e2;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warn: #d97706;
  --warn-light: #fef3c7;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

/* 焦点样式（无障碍：键盘导航可见） */
:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-page);
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

/* ========== 整体布局（侧栏 + 主内容，可扩展） ========== */
.app-body { min-height: 100vh; }
.app-layout {
  display: flex;
  min-height: 100vh;
}
.app-sidebar {
  width: var(--sidebar-width, 240px);
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-link {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  display: block;
}
.brand-link:hover { color: var(--primary); }
.sidebar-nav {
  flex: 1;
  padding: 12px 12px 16px;
  overflow-y: auto;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, color .15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}
.nav-link:hover { background: var(--bg-page); color: var(--text); }
.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
}
.sidebar-nav-divider {
  margin: 14px 12px 8px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-hint);
}
.nav-link-module {
  border: 1px solid #a5d6a7;
  background: linear-gradient(180deg, #f1f8e9 0%, #e8f5e9 100%);
  color: #2e7d32;
  flex-wrap: wrap;
  row-gap: 4px;
}
.nav-link-module .nav-text {
  flex: 1;
  min-width: 0;
  line-height: 1.35;
}
.nav-link-module:hover {
  background: #e8f5e9;
  color: #1b5e20;
}
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #c8e6c9;
  color: #1b5e20;
}
.nav-link-module-popads {
  border-color: #a5d6a7;
  background: linear-gradient(180deg, #f1f8e9 0%, #e8f5e9 100%);
  color: #2e7d32;
}
.nav-link-module-popads:hover {
  background: #e8f5e9;
  color: #1b5e20;
}
.nav-badge-soon {
  background: #c8e6c9;
  color: #1b5e20;
}
.nav-badge-warn {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
}
.nav-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: 0.9; }
.nav-icon svg { width: 18px; height: 18px; }
.module-entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

/* ========== 概览页布局（紧凑） ========== */
.overview-page .page-header { margin-bottom: 10px; }
.overview-page .page-desc { font-size: 12px; }
.overview-config-path {
  font-size: 11px;
  color: var(--text-hint);
  word-break: break-all;
}
.overview-page .card {
  margin-bottom: 0;
  box-shadow: none;
}
.overview-page .card:hover { box-shadow: none; }
.overview-kpi-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
  margin-bottom: 14px;
  padding: 7px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.overview-kpi {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  min-width: 0;
}
.overview-kpi-pa,
.overview-kpi-popads {
  border: none;
  background: transparent;
}
.overview-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hint);
  white-space: nowrap;
}
.pill-compact {
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.35;
}
.overview-section { margin-bottom: 16px; }
.overview-section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 8px;
}
.overview-section-head--compact { margin-bottom: 8px; }
.overview-section-head .overview-section-title { margin-bottom: 0; }
.overview-section-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.overview-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-hint);
  margin: 0;
}
.overview-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}
.overview-infra-card {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  border-top-width: 2px;
  border-top-style: solid;
}
.overview-infra-card--service { border-top-color: var(--primary); }
.overview-infra-card--binom { border-top-color: #6366f1; }
.overview-infra-card--timezone { border-top-color: var(--warn); }
.overview-infra-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.overview-infra-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}
.overview-infra-body { min-width: 0; }
.overview-infra-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin-bottom: 4px;
}
.overview-infra-status-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-hint);
}
.overview-infra-msg {
  font-size: 11px;
  color: var(--text-muted);
}
.overview-infra-current {
  margin: 0 0 6px;
  font-size: 13px;
}
.overview-infra-hint {
  font-size: 11px;
  color: var(--text-hint);
  line-height: 1.45;
  margin: 0 0 6px;
}
.overview-infra-actions {
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
}
.overview-timezone-fields {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}
.overview-timezone-select,
.overview-timezone-custom {
  grid-column: 1 / -1;
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  background: #fff;
}
.overview-timezone-custom { display: none; }
.overview-timezone-fields .btn {
  grid-column: 2;
  justify-self: end;
  padding: 4px 10px;
  font-size: 12px;
}
.overview-module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.overview-module-compact {
  padding: 10px 12px;
}
.overview-module-compact--live {
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.22);
}
.card-module-popads.overview-module-compact--live {
  box-shadow: inset 0 0 0 1px rgba(22, 163, 74, 0.22);
}
.overview-module-compact-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px 10px;
  margin-bottom: 8px;
}
.overview-module-compact-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  min-width: 0;
  font-size: 13px;
}
.overview-module-compact-title strong {
  font-weight: 600;
  color: inherit;
}
.overview-module-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
}
.overview-module-badge-pa {
  background: #c8e6c9;
  color: #2e7d32;
  font-size: 9px;
  letter-spacing: -0.02em;
}
.overview-module-badge-popads {
  background: #c8e6c9;
  color: #2e7d32;
}
.overview-module-badge-domain {
  background: #dbeafe;
  color: #1d4ed8;
}
.overview-module-grid--single {
  grid-template-columns: minmax(0, 1fr);
}
.overview-module-count {
  font-size: 11px;
  color: var(--text-muted);
}
.overview-module-count strong {
  font-size: 12px;
  color: var(--text);
}
.overview-module-compact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.overview-module-compact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.overview-module-compact-row .module-status-label {
  font-size: 11px;
  min-width: auto;
  margin-left: 2px;
}
.module-toggle--compact label span {
  min-width: 36px;
  padding: 3px 8px;
  font-size: 12px;
}
.overview-module-alert {
  margin-top: 8px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  background: var(--warn-light);
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 11px;
  line-height: 1.4;
}
.overview-module-compact .module-status-meta {
  margin: 6px 0 0;
  font-size: 11px;
  color: var(--text-hint);
}
.overview-module-compact .um-overview--compact {
  margin-top: 10px;
}
.overview-module-compact--alert {
  border-left: 3px solid #ef4444;
}
.overview-module-compact--warn {
  border-left: 3px solid #f59e0b;
}
.overview-kpi-url .pill {
  min-width: 3.5rem;
  text-align: center;
}

/* URL 监控 · 概览面板（主概览 + 模块总览） */
.um-overview--compact {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  background: #f8fafc;
}
.um-overview-compact-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}
.um-overview-metrics { font-size: 12px; }
.um-automation-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.um-overview--full {
  padding: 16px 18px;
  margin-bottom: 14px;
  border-left: 3px solid var(--primary);
}
.um-overview-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.um-overview-title { margin: 0 0 4px; font-size: 16px; }
.um-overview-desc { margin: 0; font-size: 12px; }
.um-overview-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.um-health-pill--lg { font-size: 12px; padding: 4px 10px; }
.um-status-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 1200px) {
  .um-status-board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.um-status-metric {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: var(--radius-sm);
  background: #fff;
  text-align: center;
}
.um-status-metric-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.um-status-metric-value { font-size: 18px; font-weight: 700; }
.um-status-metric--critical { border-top: 3px solid #ef4444; }
.um-status-metric--warning { border-top: 3px solid #f59e0b; }
.um-status-metric--ok { border-top: 3px solid #22c55e; }
.um-overview-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 12px;
}
.um-issue-panel { border-top: 1px solid #e5e7eb; padding-top: 12px; }
.um-issue-panel--ok { border-top: 1px solid #e5e7eb; padding-top: 12px; font-size: 12px; }
.um-issue-panel-head { font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.um-issue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.um-issue-list--compact { margin-top: 8px; gap: 4px; }
.um-issue-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.um-issue-row > .um-issue-link { flex: 1; min-width: 0; }
.um-issue-ack {
  flex-shrink: 0;
  align-self: center;
  font-size: 11px;
  padding: 4px 8px;
  white-space: nowrap;
}
.um-issue {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid #e5e7eb;
}
.um-issue--critical { border-left: 3px solid #ef4444; }
.um-issue--warning { border-left: 3px solid #f59e0b; }
.um-issue--pending { border-left: 3px solid #9ca3af; }
.um-issue-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.um-issue-name { font-size: 13px; word-break: break-word; }
.um-issue-url { font-size: 11px; word-break: break-all; }
.um-issue-link {
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
}
.um-issue-link:hover { background: #f8fafc; }
.um-issue-meta { font-size: 11px; }
.dm-automation-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dm-automation-dot-ok { background: #22c55e; }
.dm-automation-dot-warning { background: #eab308; }
.dm-automation-dot-error { background: #ef4444; }
.dm-automation-dot-unknown { background: #9ca3af; }
@media (max-width: 720px) {
  .um-status-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .um-status-metric:nth-child(5) { grid-column: span 2; }
}
@media (max-width: 640px) {
  .um-status-board { grid-template-columns: 1fr; }
  .um-status-metric:nth-child(5) { grid-column: auto; }
}
@media (min-width: 961px) {
  .overview-timezone-fields {
    grid-template-columns: 1fr auto;
  }
  .overview-timezone-custom { grid-column: 1; }
}
@media (max-width: 960px) {
  .overview-status-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .overview-module-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .overview-module-compact-head {
    flex-direction: column;
    align-items: stretch;
  }
  .overview-module-compact-links { justify-content: flex-end; }
}

.card-module-entry {
  border: 1px solid #a5d6a7;
  background: linear-gradient(180deg, #fafdf7 0%, #f1f8e9 100%);
}
.card-module-entry h2 { color: #2e7d32; }
.card-module-popads {
  border-color: #a5d6a7;
  background: linear-gradient(180deg, #fafdf7 0%, #f1f8e9 100%);
}
.card-module-popads h2 { color: #2e7d32; }
.module-status-bar {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.06);
}
.card-module-popads .module-status-bar { background: rgba(255, 255, 255, 0.85); }
.module-status-row,
.module-toggle-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin-bottom: 8px;
}
.module-toggle-row { margin-bottom: 0; }
.module-status-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 72px;
}
.module-status-meta {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-hint);
  line-height: 1.5;
}
.module-toggle label span {
  min-width: 44px;
  text-align: center;
  padding: 5px 10px;
  font-size: 13px;
}
.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 1000;
  padding: 10px 14px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top .2s;
}
.skip-link:focus { top: 12px; outline: 2px solid #fff; outline-offset: 2px; }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.nav-link-logout { color: var(--text-muted); font-size: 13px; }
.nav-link-logout:hover { color: var(--danger); background: var(--danger-light); }
.app-main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  background: var(--bg-page);
}
.app-main-inner {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 24px 20px 48px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}

/* 移动端：侧栏收起到左侧外，通过类 .sidebar-open 展开覆盖 */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: var(--topbar-height, 52px);
    width: min(88vw, 280px);
    height: calc(100vh - var(--topbar-height, 52px));
    height: calc(100dvh - var(--topbar-height, 52px));
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .app-body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar-overlay {
    position: fixed;
    top: var(--topbar-height, 52px);
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0,0,0,.4);
    z-index: var(--z-overlay, 210);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
  }
  .app-sidebar {
    z-index: var(--z-drawer, 220);
  }
  .app-main { margin-left: 0; }
}
/* 汉堡在顶栏内（不进 PJAX），≤900 显示 */
.sidebar-toggle {
  display: none;
  position: relative;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: var(--radius-sm);
  background: var(--bg-card, #fff);
  box-shadow: none;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-toggle-bar {
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}
@media (max-width: 900px) {
  .sidebar-toggle { display: flex; }
  .app-main-inner {
    padding-top: max(16px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }
  /* 触控命中区：按钮不小于 40px */
  .btn, .button, button[type="submit"], .btn-small, .toggle-btn,
  .opt-row-actions .btn-small, .popads-row-actions .btn-small,
  .opt-template-row-actions .btn-small {
    min-height: 40px;
  }
  .btn-small, .toggle-btn {
    padding: 8px 12px;
  }
  .opt-workflow-step {
    min-height: 40px;
    padding: 10px 12px;
  }
  .nav-link {
    min-height: 44px;
  }
}
@media (min-width: 901px) {
  .sidebar-toggle { display: none !important; }
}

/* 页面内标题区（替代原 app-header，用于主内容区） */
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.page-header .page-desc {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.page-header .page-desc a { color: inherit; }

/* 面包屑（可扩展：新层级在此追加） */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-hint); user-select: none; }
.breadcrumb-current { color: var(--text); font-weight: 500; }

/* 模块内子导航（Zone 优化等） */
.module-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.module-tab {
  display: inline-block;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  border-radius: 6px 6px 0 0;
  transition: color .15s ease, background .15s ease;
}
.module-tab:hover {
  color: var(--text);
  background: #f8fafc;
}
.module-tab.active {
  color: var(--primary);
  font-weight: 500;
  border-bottom-color: var(--primary);
  background: #f8fafc;
}
.module-tabs-secondary {
  margin-top: 0;
  margin-bottom: 16px;
}

/* 活动配置 / 规则 子页 */
.camp-page-header {
  margin-bottom: 4px;
}
.camp-page-header h1 {
  font-size: 1.35rem;
  line-height: 1.3;
}
.camp-page-desc {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
  word-break: break-word;
}
.camp-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 12px;
  font-size: 13px;
}
.camp-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.camp-meta-item strong {
  color: var(--text);
  font-weight: 500;
}
.camp-meta-sep {
  color: var(--border);
  user-select: none;
}
.module-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.module-tab.active .module-tab-badge {
  background: rgba(5, 150, 105, 0.15);
  color: var(--primary);
}
.camp-section-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}
.camp-offer-hint {
  margin: 0 0 12px;
  line-height: 1.5;
  max-width: 52rem;
}
.camp-action-hint {
  margin: 8px 0 0;
}

/* Zone 优化规则表单 — 紧凑布局 */
.opt-rule-block {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  margin-bottom: 16px;
  padding: 0;
  overflow: visible;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
}
.opt-rule-block-traffic {
  border-top: 5px solid #059669;
}
.opt-rule-block-tracker {
  border-top: 5px solid #6366f1;
}
.opt-rule-block-pending {
  border-top-color: #94a3b8;
  opacity: 1;
}
.opt-rule-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border-radius: 6px 6px 0 0;
}
.opt-rule-block-traffic .opt-rule-block-head {
  background: linear-gradient(135deg, #064e3b 0%, #047857 55%, #059669 100%);
}
.opt-rule-block-tracker .opt-rule-block-head {
  background: linear-gradient(135deg, #312e81 0%, #4338ca 55%, #6366f1 100%);
}
.opt-rule-block-pending .opt-rule-block-head {
  background: linear-gradient(135deg, #334155 0%, #475569 100%) !important;
}
.opt-rule-block-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}
.opt-rule-num-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.opt-rule-block-traffic .opt-rule-num-badge {
  background: #fbbf24;
  color: #78350f;
  border: 1px solid #f59e0b;
}
.opt-rule-block-tracker .opt-rule-num-badge {
  background: #67e8f9;
  color: #0e7490;
  border: 1px solid #22d3ee;
}
.opt-rule-block-pending .opt-rule-num-badge {
  background: #e2e8f0;
  color: #334155;
  border-color: #cbd5e1;
  box-shadow: none;
}
.opt-rule-name {
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  letter-spacing: 0.01em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.opt-rule-block-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.opt-rule-block-meta-text {
  color: rgba(255, 255, 255, 0.88);
  font-size: 12px;
}
.aoh-rule-block {
  background: #fff;
  border-color: #cbd5e1;
}
.opt-rule-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 8px;
}
@media (max-width: 960px) {
  .opt-rule-pair {
    grid-template-columns: 1fr;
  }
}
.opt-rule-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
.opt-rule-side-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.opt-rule-side-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.opt-rule-row.black .opt-rule-side-badge {
  background: #fee2e2;
  color: #b91c1c;
}
.opt-rule-row.white .opt-rule-side-badge {
  background: #dbeafe;
  color: #1d4ed8;
}
.opt-rule-side-title strong {
  font-size: 13px;
}
.opt-rule-enabled {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}
.opt-rule-line {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 0;
  line-height: 1.35;
  overflow: visible;
}
.opt-rule-line + .opt-rule-line {
  border-top: 1px dashed rgba(15, 23, 42, 0.06);
}
.opt-rule-line-body {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.opt-rule-kw-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  padding: 2px 0;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #fff;
  margin-top: 2px;
}
.opt-rule-kw-when { background: #16a34a; }
.opt-rule-kw-if { background: #0284c7; }
.opt-rule-kw-then { background: #9333ea; }
.opt-rule-and {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  padding: 0 2px;
}
.opt-rule-then-text {
  font-size: 12px;
  font-weight: 600;
  color: #6b21a8;
}
.opt-rule-then-en {
  font-size: 11px;
  font-weight: 500;
  color: #9333ea;
}
.opt-rule-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  vertical-align: middle;
}
.opt-rule-field-label {
  font-size: 11px;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
}
.opt-rule-op {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #ecfdf5;
  color: #166534;
  white-space: nowrap;
}
.opt-rule-op-sym {
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
}
.opt-rule-op-hint {
  font-size: 10px;
  font-weight: 600;
  color: #15803d;
}
.opt-rule-row-pending { opacity: 0.88; }
.opt-rule-row {
  margin: 0;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-left-width: 3px;
  border-radius: 8px;
  overflow: visible;
}
.opt-rule-row.black {
  border-left-color: #ef4444;
  background: #fffbfb;
}
.opt-rule-row.white {
  border-left-color: #3b82f6;
  background: #fbfdff;
}
.opt-rule-row label {
  margin: 0;
  white-space: nowrap;
  font-size: 11px;
}
.opt-rule-row input[type=text],
.opt-rule-row input[type=number],
.opt-rule-row select {
  width: 72px;
  margin: 0;
  padding: 3px 5px;
  font-size: 12px;
}

/* 规则阈值自定义下拉（替代原生 datalist） */
.threshold-picker {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  vertical-align: middle;
  margin: 2px 0;
}
.threshold-picker .threshold-input {
  width: 76px;
  margin: 0;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 4px 0 0 4px;
  font-size: 12px;
  background: #fff;
}
.threshold-picker .threshold-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
  z-index: 2;
}
.threshold-toggle {
  width: 22px;
  padding: 0;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 6px 6px 0;
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.threshold-toggle:hover {
  background: #eef2ff;
  color: var(--primary);
}
.threshold-picker.is-open .threshold-toggle {
  background: #eef2ff;
  color: var(--primary);
}
.threshold-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 1200;
  min-width: 100%;
  width: max-content;
  max-width: 180px;
  max-height: 220px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  padding: 4px 0;
  -webkit-overflow-scrolling: touch;
}
.threshold-menu[hidden] {
  display: none !important;
}
.threshold-menu-item {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  padding: 7px 12px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.threshold-menu-item:hover,
.threshold-menu-item.is-focused {
  background: #f1f5f9;
}
.threshold-menu-item.is-active {
  background: #eff6ff;
  color: var(--primary);
  font-weight: 500;
}
.threshold-menu-item.is-custom {
  border-bottom: 1px dashed var(--border);
  font-style: normal;
  color: var(--text);
}
.threshold-menu-empty {
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-muted);
}

/* 页面容器（兼容：无侧栏时单页也可用） */
.app-page {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 24px 20px 48px;
}

/* 顶栏（兼容旧页或独立页，如登录后跳转前的过渡） */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  margin: -24px -20px 24px -20px;
  padding-left: max(20px, env(safe-area-inset-left));
}
.app-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}
.app-header p {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}
.app-header p a { color: inherit; }

/* 卡片 */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  margin-bottom: 20px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.card:last-child { margin-bottom: 0; }

.card h1 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 14px -24px;
  padding: 0 0 8px 27px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  border-left: 3px solid var(--primary);
}

/* 表格 */
.table-wrap {
  overflow-x: auto;
  margin-top: 8px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
/* 长表时表头粘性（在 .table-wrap 上加 .sticky-header，并设 max-height） */
.table-wrap.sticky-header {
  max-height: 60vh;
  overflow: auto;
}
.table-wrap.sticky-header th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  box-shadow: 0 1px 0 var(--border);
}
/* 宽表首列粘性（可选类） */
.table-wrap.table-sticky-first th:first-child,
.table-wrap.table-sticky-first td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg-card, #fff);
  box-shadow: 1px 0 0 var(--border, #e5e7eb);
}
.table-wrap.table-sticky-first th:first-child {
  z-index: 3;
  background: #f8fafc;
}
.table-wrap.is-wide-table table,
table.is-wide-table {
  min-width: 560px;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
/* 名称列允许换行，长名称完整显示 */
td.col-name { max-width: 280px; word-break: break-all; white-space: normal; line-height: 1.4; }
tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }

/* 标签 pill */
.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.pill-on {
  background: var(--success-light);
  color: #166534;
}
.pill-warn {
  background: #fef3c7;
  color: #92400e;
}
.pill-off {
  background: var(--danger-light);
  color: #991b1b;
}

/* 按钮基础 */
.btn, .button, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-family: inherit;
}
.btn:disabled, button:disabled { opacity: 0.7; cursor: not-allowed; }
.btn.is-loading { cursor: wait; pointer-events: none; }

.btn-primary, a.button.primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover:not(:disabled), a.button.primary:hover {
  background: var(--primary-hover);
  color: #fff;
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803d; color: #fff; }

.btn-ghost {
  background: #f1f5f9;
  color: var(--text);
}
.btn-ghost:hover:not(:disabled) { background: #e2e8f0; }

a.button {
  text-decoration: none;
  display: inline-flex;
}
a.button:not(.primary) {
  background: #475569;
  color: #fff;
}
a.button:not(.primary):hover { background: #334155; color: #fff; }

/* 小按钮（表格内） */
.btn-small {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: opacity .15s;
  font-family: inherit;
  margin-right: 6px;
}
.btn-small:last-child { margin-right: 0; }
.btn-small:hover:not(:disabled) { opacity: 0.9; }

/* 表格内开关按钮（与 btn-small 一致，便于扩展） */
.toggle-btn {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  background: var(--primary);
  color: #fff;
}
.toggle-btn:hover:not(:disabled) { opacity: 0.9; }
.toggle-btn:disabled { opacity: 0.7; cursor: not-allowed; }

/* 表单内联 */
form.inline { display: inline; margin: 0 6px 0 0; padding: 0; }
form.inline button, form.inline .btn { margin-right: 0; }

/* 活动管理：行内操作区 */
.camp-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 7.5rem;
}
.camp-row-actions form.inline {
  display: inline-flex;
  margin: 0;
}
.camp-row-actions .btn,
.camp-row-actions .toggle-btn,
.camp-row-actions .remove-btn {
  white-space: nowrap;
  flex-shrink: 0;
}
.camp-col-op {
  vertical-align: middle;
}
@media (min-width: 901px) {
  .camp-col-op {
    white-space: nowrap;
  }
}

/* 链接 */
.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.back-link:hover { text-decoration: underline; color: var(--primary-hover); }

/* 代码/路径 */
code {
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
}
pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.5;
}

/* 提示文案 */
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-hint { color: var(--text-hint); font-size: 12px; }

/* 信息行（活动配置页） */
.info-row { margin: 8px 0; }
.info-label { font-weight: 500; display: inline-block; width: 100px; color: var(--text-muted); }

/* 对话框覆盖层（保持与现有 JS 兼容） */
.custom-dialog-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s;
}
.custom-dialog {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,.25);
  animation: slideIn 0.2s;
  border: 1px solid var(--border);
}
.custom-dialog-title { font-size: 1rem; font-weight: 600; margin-bottom: 10px; color: var(--text); }
.custom-dialog-message { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; line-height: 1.5; white-space: pre-line; }
.custom-dialog-buttons { display: flex; gap: 10px; justify-content: flex-end; }
.custom-dialog-btn {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  font-family: inherit;
}
.custom-dialog-btn-yes { background: var(--primary); color: #fff; }
.custom-dialog-btn-yes:hover { background: var(--primary-hover); color: #fff; }
.custom-dialog-btn-no { background: #e2e8f0; color: var(--text); }
.custom-dialog-btn-no:hover { background: #cbd5e1; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideIn { from { transform: translateY(-12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* 服务状态区按钮组 */
.action-group { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 0; }
.action-group .btn, .action-group .button, .action-group form { margin: 0; }

/* 闪信（Flask flash） */
.flash-list { margin: 0 0 16px; padding: 0; list-style: none; }
.flash-list li {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
}
.flash-success { background: var(--success-light); color: #166534; }
.flash-danger { background: var(--danger-light); color: #991b1b; }
.flash-warning { background: var(--warn-light); color: #92400e; }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert-success { background: var(--success-light); color: #166534; }
.alert-danger { background: var(--danger-light); color: #991b1b; }
.alert-warning { background: var(--warn-light); color: #92400e; }

/* ========== 工具类（减少内联 style，便于扩展） ========== */
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.ml-8 { margin-left: 8px; }
.card-hint { font-size: 12px; color: var(--text-muted); }
.card-hint.ml-8 { display: inline; }
.action-group.action-group-top { margin-top: 16px; }
/* 获取 IDs 结果框（Propeller/PopAds 等） */
.fetch-result-box {
  display: none;
  margin-bottom: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.fetch-result-box.show { display: block; }
.fetch-result-box.success { background: var(--success-light); color: #166534; }
.fetch-result-box.error { background: var(--danger-light); color: #991b1b; }
/* 区块说明 + 按钮同一行 */
.fetch-block { margin-bottom: 12px; }
.fetch-block .btn { margin-right: 8px; }
.empty-state { color: var(--text-muted); font-size: 13px; }
/* 页面内成功/提示条（如：已加入托管、刷新成功） */
.toast-success {
  background: var(--success-light);
  color: #166534;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
  font-size: 13px;
}
.toast-error {
  background: var(--danger-light);
  color: #991b1b;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
/* 页面级 toast 容器（用于替代 alert） */
.page-toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: min(360px, calc(100% - 24px));
  max-width: 90%;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0,0,0,.15);
  font-size: 14px;
  animation: toastIn .25s ease;
}
.page-toast.toast-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.page-toast.toast-success { background: var(--success-light); color: #166534; border: 1px solid #bbf7d0; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
/* 设置表单（控制日志/执行日志等） */
.form-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.form-inline .label-inline { color: var(--text-muted); font-size: 13px; }
.form-inline .input-num { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.form-inline .checkbox-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.form-inline .checkbox-inline input { margin: 0; }
.card-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.card-section:last-of-type { border-bottom: none; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--text); }

/* Zone 优化模块 */
.callout-info {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text);
  background: var(--primary-light);
  border: 1px solid #99f6e4;
  border-radius: var(--radius-sm);
}
.opt-workflow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.opt-workflow-label { font-weight: 600; color: var(--text-muted); margin-right: 4px; }
.opt-workflow-step {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--text-muted);
  text-decoration: none;
  border: 1px solid var(--border);
}
.opt-workflow-step:hover { color: var(--primary); border-color: var(--primary); }
.opt-workflow-step.current {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}
.opt-workflow-sep { color: var(--text-hint); }
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
}
.stat-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-card-value { font-size: 1.25rem; font-weight: 700; color: var(--text); }
.stat-card-value.ok { color: var(--success); }
.stat-card-value.stop { color: var(--danger); }
.pill-neutral {
  background: #f1f5f9;
  color: var(--text-muted);
}
.pill-info {
  background: #dbeafe;
  color: #1d4ed8;
}
.code-panel {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  max-height: 320px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.5;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
}
.card-flush { padding: 0; overflow: hidden; }
.card-flush .table-wrap { margin: 0; }
.sidebar-brand-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 400;
}

/* 受管活动空状态区块 */
.empty-state-block {
  padding: 24px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}
.empty-state-block code { font-size: 12px; }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* Zone 优化 · 活动列表 */
.opt-campaigns-table .pill {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  white-space: nowrap;
}
.pill-format {
  background: #eef2ff;
  color: #3730a3;
}
.pill-status-working {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.pill-status-paused,
.pill-status-stopped {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
}
.pill-status-stopped {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}
.pill-status-moderation {
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #93c5fd;
}
.pill-status-draft,
.pill-status-rejected,
.pill-status-neutral {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.pill-auto-always {
  background: #7c3aed;
  color: #fff;
}
.pill-auto-yes {
  background: #2563eb;
  color: #fff;
}
.pill-auto-no {
  background: #e2e8f0;
  color: #64748b;
}
.pill-run-yes {
  background: #16a34a;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 0 1px #15803d inset;
}
.pill-run-no {
  background: #f8fafc;
  color: #94a3b8;
  border: 1px dashed #cbd5e1;
}
.opt-row-actions .btn-small {
  min-width: 52px;
  font-weight: 600;
}
.opt-row-actions .btn-primary.btn-small {
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.35);
}
.opt-list-toolbar {
  margin-top: 16px;
  gap: 10px;
}

/* 运行页 */
.opt-op-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.opt-op-stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.opt-op-stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.opt-op-stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}
.opt-op-stat-meta {
  font-size: 12px;
  color: var(--text-hint);
}
.opt-op-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}
@media (min-width: 960px) {
  .opt-op-layout {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  }
}
.opt-op-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.opt-op-card-head h2 { margin: 0; }
.opt-op-form-rows { margin-top: 8px; }
.opt-op-form-row {
  display: grid;
  grid-template-columns: minmax(120px, 140px) 1fr;
  gap: 8px 16px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.opt-op-form-row:last-child { border-bottom: none; }
.opt-op-form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.opt-op-form-hint {
  grid-column: 2;
  margin-top: -6px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}
@media (max-width: 559px) {
  .opt-op-form-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .opt-op-form-hint { grid-column: 1; margin-top: 0; }
}
.opt-op-segment {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}
.opt-op-segment label {
  margin: 0;
  cursor: pointer;
}
.opt-op-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.opt-op-segment span {
  display: block;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  transition: background .15s ease, color .15s ease;
}
.opt-op-segment input:checked + span {
  background: var(--primary);
  color: #fff;
}
.opt-op-segment label:first-child span { border-right: 1px solid var(--border); }
.opt-op-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.opt-op-switch input { width: 16px; height: 16px; accent-color: var(--primary); }
.opt-op-card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.opt-op-service-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 12px 0 0;
}
.opt-op-run-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}
@media (min-width: 480px) {
  .opt-op-run-actions { grid-template-columns: 1fr 1fr; }
}
.opt-op-run-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 14px 16px;
  text-align: left;
  border-radius: var(--radius-sm);
  min-height: 72px;
}
.opt-op-run-btn strong { font-size: 14px; }
.opt-op-run-btn small {
  font-size: 12px;
  font-weight: 400;
  opacity: 0.85;
  line-height: 1.35;
}
.btn.opt-op-run-btn.btn-primary small { color: #dbeafe; }
.btn.opt-op-run-btn.btn-danger small { color: #fecaca; }
.opt-op-run-warn {
  margin-top: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  line-height: 1.45;
}
.opt-op-result {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}
.opt-op-result-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 14px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.opt-op-result-head.ok { background: #f0fdf4; color: #166534; }
.opt-op-result-head.err { background: #fef2f2; color: #991b1b; }
.opt-op-result-list {
  margin: 0;
  padding: 10px 14px 10px 30px;
  font-size: 13px;
  line-height: 1.55;
  max-height: 220px;
  overflow: auto;
}
.opt-op-result-list li { margin: 4px 0; }
.opt-op-result-list li.muted { color: var(--text-muted); }
.opt-op-result-list li.err { color: var(--danger); }
.opt-op-result-raw {
  border-top: 1px solid var(--border);
}
.opt-op-result-raw summary {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.opt-op-result-raw pre {
  margin: 0;
  padding: 12px 14px;
  max-height: 240px;
  overflow: auto;
  font-size: 11px;
  line-height: 1.45;
  background: #0f172a;
  color: #e2e8f0;
}
.opt-op-loading .opt-op-run-btn { opacity: 0.65; pointer-events: none; }

/* ========== 全站移动端适配（≤900px 平板/手机，≤480px 小屏手机） ========== */
@media (max-width: 900px) {
  .page-header h1 { font-size: 1.2rem; }
  .page-header .page-desc { font-size: 12px; word-break: break-word; }

  .card { padding: 14px 12px; }

  .opt-workflow {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 10px 12px;
    margin-bottom: 14px;
  }
  .opt-workflow-label { margin-right: 0; margin-bottom: 2px; }
  .opt-workflow-sep { display: none; }
  .opt-workflow-step {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .overview-kpi-strip {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 10px;
    padding: 10px 12px;
  }
  .overview-kpi {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px;
  }
  .overview-kpi-label {
    white-space: normal;
    line-height: 1.3;
    font-size: 10px;
  }

  .overview-section-head {
    flex-direction: column;
    align-items: stretch;
  }
  .overview-section-links {
    width: 100%;
    justify-content: stretch;
  }
  .overview-section-links .btn {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
  }

  .overview-module-compact-title {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .overview-module-count { width: 100%; }
  .overview-module-compact-row {
    gap: 8px;
  }
  .overview-module-compact-row .module-status-label {
    min-width: 0;
  }

  .overview-infra-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .overview-infra-actions .btn,
  .overview-infra-actions form {
    width: 100%;
  }
  .overview-infra-actions .btn { justify-content: center; }

  .overview-timezone-fields {
    grid-template-columns: 1fr;
  }
  .overview-timezone-select,
  .overview-timezone-custom {
    grid-column: 1;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-wrap.is-wide-table table,
  table.is-wide-table {
    min-width: 0;
    width: max(100%, max-content);
  }
  .table-wrap th,
  .table-wrap td {
    padding: 8px 10px;
    font-size: 12px;
  }

  .action-group:not(.popads-row-actions):not(.opt-row-actions):not(.opt-template-row-actions) {
    flex-direction: column;
    align-items: stretch;
    margin-top: 8px;
  }
  .action-group:not(.popads-row-actions):not(.opt-row-actions):not(.opt-template-row-actions) .btn {
    width: 100%;
    justify-content: center;
  }

  .popads-row-actions,
  .opt-row-actions,
  .opt-template-row-actions {
    flex-wrap: wrap;
  }

  .opt-op-stat-grid {
    grid-template-columns: 1fr;
  }
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .opt-op-card-head {
    flex-direction: column;
    align-items: stretch;
  }
  .opt-op-card-foot {
    flex-direction: column;
    align-items: stretch;
  }
  .opt-op-card-foot .btn {
    width: 100%;
    justify-content: center;
  }
  .opt-op-service-row {
    flex-direction: column;
    align-items: stretch;
  }

  .module-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .module-tab {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .custom-dialog {
    width: min(400px, calc(100% - 32px));
    max-width: none;
    margin: 16px;
  }
  .custom-dialog-buttons {
    flex-direction: column-reverse;
  }
  .custom-dialog-btn {
    width: 100%;
    justify-content: center;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }
  .form-inline .input-num,
  .form-inline input,
  .form-inline select {
    width: 100%;
    max-width: none;
  }

  .nav-badge {
    font-size: 9px;
    letter-spacing: -0.02em;
    padding: 2px 5px;
  }
}

@media (max-width: 640px) {
  .overview-kpi-strip {
    grid-template-columns: 1fr;
  }
  .overview-module-compact-links {
    width: 100%;
    justify-content: stretch;
  }
  .overview-module-compact-links .btn {
    flex: 1;
    justify-content: center;
  }
  .opt-op-run-actions {
    grid-template-columns: 1fr;
  }
  .popads-rules-table .popads-row-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .popads-rules-table .popads-row-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .page-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-header .dm-header-actions,
  .camp-page-header .dm-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }
  .page-header .dm-header-actions .btn,
  .camp-page-header .dm-header-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  .form-actions,
  .card-footer-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .form-actions .btn,
  .card-footer-actions .btn {
    width: 100%;
    justify-content: center;
  }
  .card input[type="text"],
  .card input[type="password"],
  .card input[type="number"],
  .card input[type="email"],
  .card input[type="url"],
  .card input[type="search"],
  .card select,
  .card textarea,
  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
  a.pill, .pill[href], button.pill {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
  }
}

@media (max-width: 480px) {
  .app-main-inner {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }
  .sidebar-brand { padding: 16px 14px; }
  .brand-link { font-size: 0.95rem; }
  .nav-link { font-size: 13px; padding: 9px 10px; }
  .opt-op-segment span {
    padding: 7px 12px;
    font-size: 12px;
  }
}
