/* YG 云控 - 用户端 / 管理端共用样式 */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --text: #101828;
  --muted: #667085;
  --faint: #98a2b3;
  --primary: #2f6fed;
  --primary-hover: #2459c9;
  --primary-soft: #edf3ff;
  --primary-ink: #ffffff;
  --ok: #12a150;
  --ok-soft: #e3f8ec;
  --warn: #c27803;
  --warn-soft: #fff4dc;
  --bad: #d92d20;
  --bad-soft: #fee9e7;
  --info: #0b7bc1;
  --info-soft: #e3f2fc;
  --gray-soft: #eef0f3;
  --code-bg: #0f1420;
  --code-fg: #d7e0ee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
  --shadow-lg: 0 20px 50px rgba(16, 24, 40, .22);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1b2029;
    --line: #262c37;
    --line-strong: #343c4a;
    --text: #e8ebf0;
    --muted: #9aa4b2;
    --faint: #6b7584;
    --primary: #4c86ff;
    --primary-hover: #6a9aff;
    --primary-soft: #1a2640;
    --ok: #34c472;
    --ok-soft: #12291c;
    --warn: #e0a028;
    --warn-soft: #2d2412;
    --bad: #f0605a;
    --bad-soft: #321716;
    --info: #3fa6e8;
    --info-soft: #13283a;
    --gray-soft: #222833;
    --code-bg: #0a0d12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 20px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }
.hide { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ---------- 品牌 ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, #2f6fed, #7c4dff);
  color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .5px;
  display: grid; place-items: center;
}
.brand b { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand.sm .logo { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn.block { width: 100%; }
.btn.lg { height: 42px; font-size: 15px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 14px; }
.field > label, .field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%; height: 38px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 80px; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.code-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; line-height: 1.55; min-height: 260px; tab-size: 2;
  background: var(--code-bg); color: var(--code-fg); border-color: var(--code-bg);
}
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* 开关 */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong);
  cursor: pointer; transition: background .2s;
}
.switch span::after {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------- 卡片 / 布局 ---------- */
/* 宽屏自适应：内容区随窗口宽度铺满，两侧留边 */
.container { width: 100%; margin: 0; padding: 22px 28px 60px; }
@media (max-width: 760px) { .container { padding: 16px 14px 60px; } }
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.pager .btn.xs { min-width: 30px; }
.pager .pager-size { height: 26px; width: auto; min-width: 0; padding: 0 6px; font-size: 12.5px; }
.pager .pager-jump { height: 26px; width: 64px; padding: 0 6px; font-size: 12.5px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; margin-bottom: 14px; }
.card-title .spacer { flex: 1; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head > div:first-child { flex: 1; min-width: 220px; }
.page-head p { margin-top: 4px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }
.toolbar .search { flex: 1; min-width: 180px; max-width: 360px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: none; margin: 22px 2px 10px; display: flex; align-items: center; gap: 10px; }

/* 统计 */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: 12.5px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.3px; }
.stat .s { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- 徽标 / 状态 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--gray-soft); color: var(--muted);
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.pulse .dot { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.chip { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--gray-soft); color: var(--muted); font-size: 12px; margin: 2px 4px 2px 0; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.table { width: 100%; border-collapse: collapse; min-width: 640px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table td.actions { white-space: nowrap; text-align: right; }
.table td.actions .btn + .btn { margin-left: 4px; }

/* ---------- 列表项 ---------- */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item.clickable { cursor: pointer; border-radius: 8px; }
.list-item.clickable:hover { background: var(--surface-2); }

/* ---------- 空状态 / 加载 ---------- */
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .icon { font-size: 30px; margin-bottom: 8px; opacity: .7; }
.empty b { display: block; color: var(--text); margin-bottom: 4px; font-size: 15px; }
.loading { padding: 26px; text-align: center; color: var(--muted); }
.notice {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--text); border: 1px solid var(--warn-soft);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
  margin-bottom: 16px; font-size: 13.5px;
}
.notice.info { background: var(--info-soft); border-color: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

/* ---------- 可多选标签（下发目标） ---------- */
.pick-label { font-size: 12px; color: var(--muted); margin: 8px 0 6px; }
.pick-list { display: flex; flex-wrap: wrap; gap: 6px; max-height: 168px; overflow-y: auto; padding: 2px; }
.pick {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.pick:hover { border-color: var(--primary); }
.pick.on { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.pick.via { border-style: dashed; }
.sdot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.sdot.ok { background: var(--ok); }
.sdot.warn { background: var(--warn); }

/* ---------- 数据管理 ---------- */
.data-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .data-layout { grid-template-columns: 1fr; } }
.group-list { display: flex; flex-direction: column; gap: 4px; }
.group-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent; background: none; font: inherit; color: inherit; text-align: left; width: 100%;
}
.group-item:hover { background: var(--surface-2); }
.group-item.on { background: var(--primary-soft); border-color: var(--primary); }
.group-item .n { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-item .c { font-size: 12px; color: var(--muted); white-space: nowrap; }
.text-item { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.text-item:last-child { border-bottom: 0; }
.text-item .seq { color: var(--faint); font-size: 12px; min-width: 42px; padding-top: 2px; font-variant-numeric: tabular-nums; }
.text-item .body { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.text-item .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.text-item.used .body { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.img-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); position: relative; }
.img-card img { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; background: var(--gray-soft); }
.img-card img.broken { object-fit: contain; }
.img-card .cap { padding: 6px 8px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.img-card .cap .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.img-card.used img { opacity: .4; }
.img-card .del { position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; display: none; }
.img-card:hover .del { display: block; }
@media (hover: none) { .img-card .del { display: block; } }
.progress { height: 6px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .2s; }

/* ---------- 代码 / 日志 ---------- */
pre.log {
  margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--code-bg); color: var(--code-fg);
  font-size: 12.5px; line-height: 1.6; max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}
pre.log .ok { color: #5ee08f; }
pre.log .bad { color: #ff8a80; }
pre.log .warn { color: #ffd166; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(10, 14, 22, .5);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; overflow-y: auto;
  animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  border: 1px solid var(--line); animation: pop .18s ease-out;
}
.modal.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { flex: 1; font-size: 16px; }
.modal-close { width: 30px; height: 30px; border: 0; background: none; border-radius: 8px; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }
.modal-close:hover { background: var(--gray-soft); color: var(--text); }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 14px 14px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* 参数编辑器 */
.schema-row { display: grid; grid-template-columns: 1fr 1.2fr 100px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.schema-row .input, .schema-row .select { height: 34px; font-size: 13px; }
.schema-row .opts { grid-column: 1 / -2; }
.schema-head { display: grid; grid-template-columns: 1fr 1.2fr 100px 1fr auto; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; padding-right: 40px; }
@media (max-width: 640px) {
  .schema-row, .schema-head { grid-template-columns: 1fr 1fr; }
  .schema-head { display: none; }
}
details.cheatsheet { margin-top: 10px; font-size: 13px; }
details.cheatsheet summary { cursor: pointer; color: var(--primary); font-weight: 600; }
details.cheatsheet table { width: 100%; border-collapse: collapse; margin-top: 8px; }
details.cheatsheet td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
details.cheatsheet td:first-child { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; white-space: nowrap; color: var(--primary); }

/* ---------- 提示条 ---------- */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; padding: 10px 16px; border-radius: 10px; background: #1d2433; color: #fff;
  box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: min(92vw, 460px); animation: pop .18s ease-out;
}
.toast.ok { background: #0f7a3d; }
.toast.bad { background: #b42318; }

/* ---------- 登录页 ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 28px 24px; }
.auth-card .brand { margin-bottom: 22px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--gray-soft); border-radius: 10px; padding: 3px; margin-bottom: 18px; }
.seg button { height: 32px; border: 0; background: none; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: -4px 0 10px; }
