:root {
  /* 强制浅色原生控件：避免 macOS 深色模式下 input/select/datetime 变黑 */
  color-scheme: light;
  --bg: #f1f5f9;
  --panel: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --sidebar: #0f172a;
  --sidebar-text: #cbd5e1;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
/* 跨平台字体栈：macOS 用苹方，Windows 用微软雅黑，Linux 用 Noto/文泉驿，最后 sans-serif 兜底 */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
/* 表单控件统一继承字体，避免各平台原生控件字体不一致 */
input, select, textarea, button { font-family: inherit; }
/* 浏览器自动填充（Mac Safari / Windows Chrome）统一为白底深字，避免黄底破坏配色 */
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 10000s ease-in-out 0s;
}
/* 数字输入框隐藏 spinner（各浏览器样式不一），保留键盘上下调节 */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none; margin: 0;
}
/* 日期控件在 Safari/Chrome 的高度与图标一致性 */
input[type="datetime-local"] { -webkit-appearance: none; appearance: none; }
input[type="datetime-local"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .6; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #2563eb 100%); }
.login-card { width: 360px; background: #fff; border-radius: 16px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-logo { width: 52px; height: 52px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 22px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-sub { color: var(--muted); margin: 0 0 24px; font-size: 13px; }
.login-card label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-card button { width: 100%; height: 44px; margin-top: 22px; background: var(--primary); color: #fff; border: none; border-radius: 10px; font-size: 15px; cursor: pointer; }
.login-card button:hover { background: var(--primary-dark); }
.login-error { color: var(--danger); margin-top: 10px; font-size: 13px; min-height: 18px; }

/* 布局 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 224px; background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.brand-name { font-size: 15px; font-weight: 600; color: #fff; }
.nav { flex: 1; padding: 8px 10px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 9px; cursor: pointer; color: var(--sidebar-text); margin-bottom: 4px; transition: background .15s; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 16px 18px; border-top: 1px solid rgba(255,255,255,.08); }
.user-name { color: #fff; font-weight: 600; margin-bottom: 10px; }
.logout-btn { width: 100%; padding: 8px; background: rgba(255,255,255,.08); color: #fff; border: none; border-radius: 8px; cursor: pointer; }
.logout-btn:hover { background: rgba(255,255,255,.16); }

.content { flex: 1; padding: 24px 28px; overflow-x: hidden; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 22px; }
.page-desc { color: var(--muted); font-size: 13px; }
.page-head .btn { margin-left: auto; }

.view { display: none; }
.view.active { display: block; }

/* 卡片 */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 13px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card .value.small { font-size: 20px; }

/* 面板 / 表格 */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.panel-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.table tr:last-child td { border-bottom: none; }
.table td.wrap { white-space: normal; word-break: break-all; }
.table-wrap { overflow-x: auto; }
/* 主体配置：协议列超长时省略，悬停可看完整值 */
.table td.cell-agree { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.cell-agree a { color: var(--primary); text-decoration: none; }
.table td.cell-agree a:hover { text-decoration: underline; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: #dcfce7; color: #15803d; }
.badge.off { background: #fee2e2; color: #b91c1c; }
.badge.gray { background: #e2e8f0; color: #475569; }

/* 按钮 */
.btn { display: inline-block; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; font-size: 13px; }
.btn:hover { background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 4px 10px; font-size: 12px; margin-right: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.field label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; height: 38px; border: 1px solid var(--border); border-radius: 8px; padding: 0 10px; font-size: 14px; background: #fff; }
.field textarea { height: auto; padding: 8px 10px; resize: vertical; }
.field input:focus, .field select:focus { outline: none; border-color: var(--primary); }
.field.full { grid-column: 1 / -1; }
.form-panel .panel-title { margin-bottom: 18px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { width: 520px; max-width: 92vw; background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px; max-height: 78vh; overflow-y: auto; }
.modal-body .field { margin-bottom: 14px; }
.modal.wide { width: 880px; }
.form-section { margin-bottom: 22px; }
.form-section > .section-title { font-size: 14px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); color: var(--primary); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ad-group { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: #f8fafc; }
.ad-group .ad-title { font-weight: 600; margin-bottom: 10px; font-size: 13px; }
.scene-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.scene-row input.name { width: 160px; height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; }
.scene-formats { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.scene-formats label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); cursor: pointer; }
.key-hint {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eef2f7;
  border: 1px solid #dbe3ec;
  color: #475569;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.5;
  vertical-align: middle;
}
@media (max-width: 640px) { .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* 图表 */
.chart { width: 100%; height: 300px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 960px) { .grid-2 { grid-template-columns: 1fr; } .form-grid { grid-template-columns: 1fr; } .sidebar { width: 64px; } .brand-name, .nav-item span:last-child, .user-name { display: none; } }

/* 过滤条 */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 13px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.filter-bar select { height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; }

/* toast */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 11px 20px; border-radius: 10px; z-index: 200; box-shadow: 0 8px 30px rgba(0,0,0,.3); font-size: 14px; }
.toast.error { background: var(--danger); }

/* ===================== 策略弹窗（美化） ===================== */
.modal.wide { width: 940px; }
.strategy-form { display: flex; flex-direction: column; }
.strategy-form .form-section { margin-bottom: 20px; }
.strategy-form .section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
  margin-bottom: 6px; padding-bottom: 0; border-bottom: none;
}
.strategy-form .sec-idx {
  width: 20px; height: 20px; border-radius: 6px; background: #eff6ff; color: var(--primary);
  font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.strategy-form .section-hint { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.strategy-form .grid-2, .strategy-form .grid-3 { gap: 14px; }
.strategy-form .field { margin-bottom: 14px; }
.strategy-form .field label { color: #475569; font-weight: 500; }
.strategy-form .field label em { color: var(--danger); font-style: normal; margin-left: 2px; }
.strategy-form .field input, .strategy-form .field select {
  height: 40px; border-radius: 9px; border-color: #dbe2ea; background: #fbfdff;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.strategy-form .field input:hover, .strategy-form .field select:hover { border-color: #c3cedb; }
.strategy-form .field input:focus, .strategy-form .field select:focus {
  background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.strategy-form .key-hint { display: none; }

/* 广告配置：两列卡片 */
.ad-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ad-group {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px;
  background: #fff; margin-bottom: 0; transition: border-color .15s, box-shadow .15s;
}
.ad-group:hover { border-color: #c3cedb; box-shadow: 0 2px 10px rgba(15,23,42,.05); }
.ad-group .ad-title { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.ad-group .ad-title::before { content: ''; width: 3px; height: 12px; border-radius: 2px; background: var(--primary); }
.ad-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ad-fields .field { margin-bottom: 0; }
.ad-fields .field label { font-size: 12px; }

/* 场景配置：卡片行 */
.scene-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  margin-bottom: 8px; background: #fff;
}
.scene-row select.name { width: 190px; height: 36px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; }
.scene-formats { display: flex; flex-wrap: wrap; gap: 6px 10px; }
.scene-formats label {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #475569;
  cursor: pointer; padding: 4px 9px; border-radius: 7px; background: #f8fafc; border: 1px solid transparent;
  transition: background .15s, border-color .15s;
}
.scene-formats label:hover { background: #eff6ff; border-color: #dbeafe; }
.scene-formats input { accent-color: var(--primary); }

/* 场景勾选顺序（数组排位） */
.scene-formats-wrap { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 6px; }
.scene-formats label.scene-fmt { position: relative; }
.scene-formats label.scene-fmt:has(input:checked) { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.fmt-order {
  display: none; min-width: 22px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: 11px; font-weight: 700;
  line-height: 18px; text-align: center;
}
.fmt-order.on { display: inline-block; }
.scene-order { font-size: 12px; color: #475569; line-height: 1.6; }
.scene-order b { color: var(--primary); font-weight: 700; }
.scene-order .ord-empty { color: #94a3b8; }
.scene-empty {
  color: var(--muted); font-size: 13px; padding: 14px; text-align: center;
  border: 1px dashed var(--border); border-radius: 10px; background: #f8fafc; margin-bottom: 10px;
}

/* 底部操作栏（跟随滚动，始终可见） */
.form-actions {
  position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 0 4px; margin-top: 6px;
  background: rgba(255,255,255,.96); border-top: 1px solid var(--border);
}
.form-actions .btn { padding: 9px 20px; }
.btn.ghost { background: #f8fafc; }

@media (max-width: 720px) {
  .ad-grid, .ad-fields, .strategy-form .grid-2 { grid-template-columns: 1fr; }
}

/* ---- 时间字段：毫秒输入 + 右侧秒数提示 ---- */
.input-unit { display: flex; align-items: center; gap: 8px; }
.input-unit input { flex: 1; min-width: 0; }
.unit-hint {
  flex: none; font-size: 12px; font-weight: 600; color: #0f766e;
  background: #ecfdf5; border: 1px solid #d1fae5; border-radius: 6px;
  padding: 3px 7px; white-space: nowrap;
}
.ad-fields .input-unit { gap: 5px; }
.ad-fields .unit-hint { font-size: 11px; padding: 2px 5px; }

/* ---- 分区配色：四个分区各一种主色，克制点缀 ---- */
.strategy-form .form-section:nth-of-type(1) { --sec: #2563eb; --sec-bg: #eff6ff; }
.strategy-form .form-section:nth-of-type(2) { --sec: #059669; --sec-bg: #ecfdf5; }
.strategy-form .form-section:nth-of-type(3) { --sec: #ea580c; --sec-bg: #fff7ed; }
.strategy-form .form-section:nth-of-type(4) { --sec: #7c3aed; --sec-bg: #f5f3ff; }
.strategy-form .sec-idx { background: var(--sec-bg); color: var(--sec); }
.strategy-form .section-title::after {
  content: ''; flex: 1; height: 1px; margin-left: 6px;
  background: linear-gradient(to right, var(--sec-bg), transparent);
}
.strategy-form .form-section + .form-section {
  border-top: 1px dashed #eef2f7; padding-top: 16px;
}

/* 匹配规则区做成浅蓝卡片，增加块面层次 */
.strategy-form .form-section:nth-of-type(1) .grid-2 {
  background: #f8fbff; border: 1px solid #e6effc; border-radius: 12px;
  padding: 16px 16px 2px;
}

/* 弹窗头部淡渐变、底部操作栏浅底色 */
.modal-head { background: linear-gradient(135deg, #f6f9ff 0%, #ffffff 62%); }
.form-actions { background: #fbfcff; }

/* ---- 应用图标 ---- */
.app-icon {
  width: 36px; height: 36px; border-radius: 8px; object-fit: cover;
  border: 1px solid var(--border); background: #f8fafc; display: block;
}
.icon-upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.icon-upload input[type=file] { font-size: 12px; color: var(--muted); }
.icon-preview {
  width: 56px; height: 56px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--border); background: #f8fafc;
}
.icon-hint { color: var(--muted); font-size: 12px; word-break: break-all; }

/* ---- 图标上传（整块可点击） ---- */
.icon-uploader {
  display: flex; align-items: center; gap: 16px; padding: 16px;
  border: 1.5px dashed #cbd5e1; border-radius: 12px; background: #fbfdff;
  cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
}
.icon-uploader:hover { border-color: var(--primary); background: #f2f8ff; box-shadow: 0 0 0 3px rgba(37,99,235,.08); }
.icon-uploader .icon-preview {
  width: 64px; height: 64px; border-radius: 14px; object-fit: cover;
  border: 1px solid var(--border); background: #eef2f7; flex: none;
}
.icon-upload-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.icon-upload-text strong { font-size: 13px; color: var(--text); }
.icon-upload-text span { font-size: 12px; color: var(--muted); }
.icon-upload-text .icon-filename { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

/* ---- 广告位配置（分组：应用内 / Goblin） ---- */
.ad-block {
  border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 12px;
}
.ad-block-app { background: linear-gradient(180deg, #f7fbff 0%, #ffffff 100%); border-color: #dfeafb; }
.ad-block-goblin { background: linear-gradient(180deg, #faf8ff 0%, #ffffff 100%); border-color: #e9e2fb; }

.ad-block-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.ad-block-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.ad-block-app .ad-block-dot { background: #2563eb; box-shadow: 0 0 0 3px #dbeafe; }
.ad-block-goblin .ad-block-dot { background: #7c3aed; box-shadow: 0 0 0 3px #ede9fe; }
.ad-block-title { font-size: 13px; font-weight: 700; }
.ad-block-app .ad-block-title { color: #1d4ed8; }
.ad-block-goblin .ad-block-title { color: #6d28d9; }
.ad-block-sub { font-size: 12px; color: var(--muted); margin-left: auto; }

/* 自适应列数：宽度不够自动换行，绝不出现横向滚动 */
.ad-units { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }

/* Goblin：竖排行式，一行一个（左标题 + 右输入），3 个也不会挤 */
.ad-units-goblin { grid-template-columns: 1fr; }
.ad-block-goblin .ad-unit { display: flex; align-items: center; gap: 10px; }
.ad-block-goblin .ad-unit-head { margin-bottom: 0; flex: none; }
.ad-block-goblin .ad-unit-list { flex: 1; min-width: 0; }

.ad-unit {
  border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 12px;
  background: #fff; transition: border-color .15s, box-shadow .15s; min-width: 0;
}
.ad-unit:hover { border-color: #c3cedb; box-shadow: 0 2px 8px rgba(15,23,42,.05); }
.ad-block-goblin .ad-unit { border-color: #e9e2fb; }
.ad-block-goblin .ad-unit:hover { border-color: #c4b5fd; box-shadow: 0 2px 8px rgba(124,58,237,.08); }

.ad-unit-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.ad-unit-name { font-size: 13px; font-weight: 600; color: var(--text); }
.ad-block-goblin .ad-unit-name { color: #6d28d9; }
.ad-unit-tag {
  font-size: 11px; color: #6d28d9; background: #f5f3ff; border: 1px solid #e9e2fb;
  border-radius: 6px; padding: 1px 6px; flex: none;
}
.ad-unit-list { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ad-id-row { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ad-id-row input {
  flex: 1 1 0; min-width: 0; width: 100%; height: 34px; border: 1px solid var(--border);
  border-radius: 8px; padding: 0 10px; font-size: 13px; background: #fbfdff;
}
.ad-id-row input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.ad-unit-empty { color: var(--muted); font-size: 12px; padding: 4px 0; }
.ad-unit .btn.sm { margin-right: 0; }

@media (max-width: 720px) {
  .ad-block-sub { display: none; }
  .ad-block-goblin .ad-unit { flex-direction: column; align-items: stretch; }
  .ad-block-goblin .ad-unit-head { margin-bottom: 8px; }
}

/* ---- 可搜索下拉（关联策略） ---- */
.searchable-select { position: relative; }
.searchable-select .ss-input { padding-right: 34px; }
.searchable-select .ss-arrow {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; border: none; background: transparent;
  color: #94a3b8; cursor: pointer; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center; border-radius: 6px;
}
.searchable-select .ss-arrow:hover { background: #eff6ff; color: var(--primary); }
.searchable-select .ss-panel {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(15,23,42,.14);
  max-height: 240px; overflow-y: auto; padding: 4px;
}
.searchable-select .ss-option {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
}
.searchable-select .ss-option:hover { background: #eff6ff; }
.searchable-select .ss-opt-name { font-size: 13px; color: var(--text); word-break: break-all; }
.searchable-select .ss-opt-meta { font-size: 11px; color: var(--muted); }
.searchable-select .ss-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 12px; }

/* ===================== 仪表盘（健康指标） ===================== */
.dash-health { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.health-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.health-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone); }
.health-card.blue { --tone: #2563eb; } .health-card.violet { --tone: #7c3aed; }
.health-card.red { --tone: #dc2626; } .health-card.green { --tone: #16a34a; }
.health-card.teal { --tone: #0d9488; }
.hc-label { color: var(--muted); font-size: 13px; }
.hc-value { font-size: 30px; font-weight: 700; margin: 8px 0 4px; color: var(--tone); }
.hc-sub { color: #94a3b8; font-size: 12px; }

.dash-rates { display: flex; flex-direction: column; gap: 18px; padding: 6px 2px; }
.rate-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.rate-head span { font-size: 13px; color: #475569; }
.rate-head b { font-size: 18px; }
.rate-bar { height: 8px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.rate-bar span { display: block; height: 100%; border-radius: 999px; transition: width .3s; }
.rate-hint { margin-top: 5px; font-size: 11px; color: #94a3b8; }
.good { color: #16a34a !important; } .warn { color: #d97706 !important; } .bad { color: #dc2626 !important; }
.rate-bar .good { background: #22c55e; } .rate-bar .warn { background: #f59e0b; } .rate-bar .bad { background: #ef4444; }


@media (max-width: 1000px) { .dash-health { grid-template-columns: repeat(2, 1fr); } }

/* ===================== 运行环境标识（测试服/正式服） ===================== */
.env-badge {
  display: inline-block; vertical-align: middle; margin-left: 6px;
  padding: 2px 9px; border-radius: 6px; font-size: 12px; font-weight: 600;
  line-height: 1.5; white-space: nowrap; letter-spacing: .5px;
}
.env-badge.env-test {
  background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe;
}
.env-badge.env-release {
  background: #fef2f2; color: #dc2626; border: 1px solid #fecaca;
}
/* 侧边栏深色背景下的徽章（提亮） */
.sidebar .env-badge.env-test {
  background: rgba(59,130,246,.18); color: #93c5fd; border-color: rgba(59,130,246,.45);
}
.sidebar .env-badge.env-release {
  background: rgba(239,68,68,.18); color: #fca5a5; border-color: rgba(239,68,68,.45);
}

/* ===================== 数据报表 ===================== */
.muted { color: #94a3b8; }
#view-report .panel-title {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 14px;
}
.report-charts .chart { height: 360px; }
.report-filter { padding: 16px 18px; }
.rf-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rf-dates { display: flex; gap: 6px; flex-wrap: wrap; }
.rf-fields { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.rf-fields select {
  height: 36px; border: 1px solid var(--border); border-radius: 9px;
  padding: 0 10px; background: #fff; font-size: 13px; color: var(--text); min-width: 132px;
}
.rf-fields select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.rf-fields .oaid-input {
  height: 36px; min-width: 180px; border: 1px solid var(--border); border-radius: 9px;
  padding: 0 10px; font-size: 13px; background: #fff; color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.rf-fields .oaid-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.rf-custom {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 12px; padding-top: 12px; border-top: 1px dashed #eef2f7;
}
.rf-label { color: var(--muted); font-size: 13px; }
.rf-tilde { color: #94a3b8; }
.rf-custom input {
  height: 36px; border: 1px solid var(--border); border-radius: 9px; padding: 0 10px; font-size: 13px;
}
.rf-custom input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.panel-sub { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 400; }

/* 事件统计：名字 + 占比条 */
.report-stat-table td { vertical-align: middle; }
.report-stat-table .num { text-align: right; }
.report-stat-table .muted { color: #94a3b8; font-size: 11px; margin-left: 3px; }
.ratio-bar { height: 7px; border-radius: 999px; background: #eef2f7; overflow: hidden; }
.ratio-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #60a5fa, #2563eb); }
.ev-tag {
  display: inline-block; padding: 1px 7px; border-radius: 6px; font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: #eff6ff; color: #1d4ed8; border: 1px solid #dbeafe;
}
.ev-tag.alt { background: #f0fdf4; color: #15803d; border-color: #dcfce7; }
.game-cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.game-cell b { font-size: 12px; color: var(--text); font-weight: 600; }
.game-cell span { font-size: 11px; color: var(--muted); word-break: break-all; }
.empty-cell { text-align: center; color: #94a3b8; padding: 26px 0 !important; }
.table td.num, .table th.num { text-align: right; }
.table td.nowrap { white-space: nowrap; }

/* 明细表：行可点击展开全部字段 */
.report-detail-table tbody .ev-row { cursor: pointer; }
.report-detail-table tbody .ev-row:hover { background: #f8fbff; }
.ev-detail td { background: #fbfdff; padding: 0 !important; }
.kv-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 14px; padding: 14px 16px;
}
@media (max-width: 1200px) { .kv-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px)  { .kv-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kv-cell {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  padding: 6px 9px; border: 1px solid #eef2f7; border-radius: 8px; background: #fff;
  line-height: 1.5;
}
.kv-cell span { color: var(--muted); font-size: 11px; line-height: 1.4; }
.kv-cell b {
  font-weight: 500; font-size: 12px; color: var(--text);
  word-break: break-all; overflow-wrap: anywhere; max-width: 100%; line-height: 1.5;
}
.ext-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.ext-chips .kv {
  font-size: 11px; padding: 1px 6px; border-radius: 5px;
  background: #f1f5f9; color: #475569; white-space: nowrap;
}
.ext-chips .kv b { color: #334155; margin-right: 3px; font-weight: 600; }

/* 分页条 */
.pager { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; padding: 14px 2px 2px; }
.pager .pg {
  min-width: 30px; height: 30px; padding: 0 9px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); cursor: pointer;
}
.pager .pg:hover:not(:disabled) { background: #f8fafc; border-color: #cbd5e1; }
.pager .pg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .pg:disabled { opacity: .45; cursor: not-allowed; }
.pager .pg-dots { color: #94a3b8; padding: 0 2px; }
.pager .pg-info { margin-left: auto; color: var(--muted); font-size: 12px; }
.pager .pg-cur { padding: 0 10px; color: var(--muted); font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.error-detail-table td { vertical-align: middle; }
.error-detail-table th:nth-child(3), .error-detail-table th:nth-child(4) { min-width: 130px; }

@media (max-width: 720px) {
  .rf-fields { margin-left: 0; width: 100%; }
  .rf-fields select { flex: 1; }
  .pager .pg-info { margin-left: 0; width: 100%; }
}

/* ===================== 文件上传区（ywl.bin） ===================== */
/* 用 .field label.file-drop 提高优先级，覆盖 .field label 的通用样式 */
.field label.file-drop {
  display: flex; align-items: center; gap: 14px;
  margin: 0; padding: 16px;
  border: 1.5px dashed #cbd5e1; border-radius: 10px;
  background: #f8fafc; color: var(--text);
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.field label.file-drop:hover { border-color: #93c5fd; background: #f5f9ff; }
.field label.file-drop.dragover {
  border-color: var(--primary); background: #eff6ff;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .1);
}
.field label.file-drop.has-file { border-style: solid; border-color: #86efac; background: #f0fdf4; }
.file-drop input[type="file"] { display: none !important; }

.file-drop-icon {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #e0edff; color: var(--primary);
  transition: background .18s ease, color .18s ease;
}
.file-drop.has-file .file-drop-icon { background: #dcfce7; color: var(--ok); }

.file-drop-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.file-drop-body strong {
  font-size: 14px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-drop-sub { font-size: 12px; color: #94a3b8; }

.file-drop-check {
  flex: 0 0 auto; width: 22px; height: 22px; border-radius: 50%;
  display: none; align-items: center; justify-content: center;
  background: var(--ok); color: #fff; font-size: 13px; font-weight: 700;
}
.file-drop.has-file .file-drop-check { display: inline-flex; }

/* ---- SDK 协议参数说明与广告位/场景链路 ---- */
.field-help {
  display: block; margin-top: 5px; color: var(--muted); font-size: 11px;
  line-height: 1.45; overflow-wrap: anywhere;
}
.slot-editor {
  border: 1px solid var(--border); border-radius: 8px; background: #fbfdff;
  margin: 10px 0; min-width: 0;
}
.slot-editor[open] { padding-bottom: 12px; }
.slot-editor summary {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 42px; padding: 6px 12px; cursor: pointer; color: var(--text);
  font-size: 13px; font-weight: 650; overflow-wrap: anywhere;
}
.slot-editor summary .btn { flex: none; }
.slot-fields { padding: 8px 12px 0; }
.slot-fields .field { min-width: 0; }
.slot-fields input, .slot-fields select {
  width: 100%; min-width: 0; height: 36px; border: 1px solid var(--border);
  border-radius: 7px; padding: 0 9px; background: white; color: var(--text);
}
.slot-fields .field.full { grid-column: 1 / -1; }
.slt-row {
  display: grid; grid-template-columns: repeat(4, minmax(100px, 1fr)) auto;
  align-items: end; gap: 10px; padding: 12px 0; border-bottom: 1px solid #eef2f7;
}
.slt-row label { display: flex; flex-direction: column; gap: 5px; min-width: 0; color: var(--text); font-size: 12px; }
.slt-row input, .slt-row select {
  width: 100%; min-width: 0; height: 34px; border: 1px solid var(--border);
  border-radius: 7px; padding: 0 8px; background: white; color: var(--text); font-size: 12px;
}
.slt-row .slt-caids { grid-column: 1 / -2; }
@media (max-width: 720px) {
  .slt-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .slt-row .slt-caids { grid-column: 1 / -1; }
  .slt-row .slt-del { grid-column: 2; justify-self: end; }
  .slot-fields { grid-template-columns: minmax(0, 1fr); }
  .slot-fields .field.full { grid-column: auto; }
}

/* 场景广告配置：caid 点选器（chips 与输入框分两行） */
.slt-caid-picker { display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 240px; }
.slt-caid-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.slt-caid-picker .caid-chip { padding: 4px 12px; font-size: 12px; }
.slt-caid-picker input { width: 100%; height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; }
