/* ==========================================================================
   YY门童系统 后台样式
   ========================================================================== */
:root {
  --bg: #0d1424;
  --bg-2: #131c32;
  --card: #16203a;
  --border: #24304d;
  --border-2: #2c3a5c;
  --text: #e6edf7;
  --text-2: #9cb0cc;
  --text-3: #63779a;
  --primary: #4f9dff;
  --primary-2: #2f7ae0;
  --success: #37c98a;
  --warn: #f0b429;
  --danger: #ff6b6b;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { opacity: .85; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #121b30 0%, #0e1626 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 30;
}

.logo {
  height: 62px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
}
.logo .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}

.nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text-2);
  margin-bottom: 4px;
  transition: .18s;
  font-size: 14px;
}
.nav-item:hover { background: #1a2540; color: var(--text); opacity: 1; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79,157,255,.18), rgba(79,157,255,.04));
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--primary);
}
.nav-icon { width: 18px; text-align: center; font-size: 15px; opacity: .9; }

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.8;
}

.main { flex: 1; margin-left: 208px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(19,28,50,.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.topbar .crumb { font-size: 12px; color: var(--text-3); margin-left: 10px; font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--text-2); }
.topbar-right .ver {
  padding: 3px 9px; border-radius: 20px;
  background: rgba(79,157,255,.12); color: var(--primary);
  font-size: 12px;
}

.content { padding: 22px 24px 40px; flex: 1; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.card-head {
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 8px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

/* ---------- 统计卡 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -20px; top: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, rgba(79,157,255,.14), transparent 70%);
}
.stat .label { font-size: 13px; color: var(--text-3); margin-bottom: 8px; }
.stat .value { font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.stat .value small { font-size: 13px; font-weight: 400; color: var(--text-3); margin-left: 4px; }
.stat.green .value { color: var(--success); }
.stat.blue .value { color: var(--primary); }
.stat.orange .value { color: var(--warn); }
.stat.red .value { color: var(--danger); }

/* ---------- 表格 ---------- */
table { width: 100%; border-collapse: collapse; }
table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  background: #131c32;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table td {
  padding: 13px 16px;
  border-bottom: 1px solid #1c2740;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
table tbody tr:hover { background: #1a2440; }
table tbody tr:last-child td { border-bottom: none; }
.td-mono { font-family: Consolas, Monaco, monospace; color: var(--text-2); }
.td-muted { color: var(--text-3); font-size: 12px; }
.td-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty {
  padding: 50px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}
.empty .big { font-size: 34px; margin-bottom: 10px; opacity: .35; }

/* ---------- 标签 ---------- */
.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}
.tag-green { background: rgba(55,201,138,.14); color: var(--success); }
.tag-red { background: rgba(255,107,107,.14); color: var(--danger); }
.tag-orange { background: rgba(240,180,41,.14); color: var(--warn); }
.tag-blue { background: rgba(79,157,255,.14); color: var(--primary); }
.tag-gray { background: #1e2a42; color: var(--text-3); }

.dot-status { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot-on { background: var(--success); box-shadow: 0 0 6px var(--success); }
.dot-off { background: #3c4a68; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 13px;
  transition: .18s;
  background: #1e2a42;
  color: var(--text-2);
  white-space: nowrap;
}
.btn:hover { background: #26334f; color: var(--text); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); color: #fff; }
.btn-danger { background: rgba(255,107,107,.12); color: var(--danger); border-color: rgba(255,107,107,.28); }
.btn-danger:hover { background: rgba(255,107,107,.2); color: var(--danger); }
.btn-sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer; padding: 0; font-size: 13px; }
.btn-link.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.form-row { margin-bottom: 18px; }
.form-row:last-child { margin-bottom: 0; }
.form-row > label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 7px;
}
.form-row .req { color: var(--danger); margin-left: 3px; }
.form-row .tip { font-size: 12px; color: var(--text-3); margin-top: 6px; line-height: 1.7; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  background: #0f1729;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  transition: .18s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,157,255,.12);
}
.textarea { min-height: 90px; resize: vertical; line-height: 1.7; }
.select { appearance: none; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px; }
.form-actions {
  display: flex; gap: 12px; justify-content: flex-end;
  padding-top: 18px; margin-top: 6px;
  border-top: 1px solid var(--border);
}

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 23px; border-radius: 20px;
  background: #2a3550; position: relative; transition: .2s;
}
.switch .track::after {
  content: ""; position: absolute; left: 2px; top: 2px;
  width: 19px; height: 19px; border-radius: 50%;
  background: #8ba0c0; transition: .2s;
}
.switch input:checked + .track { background: rgba(79,157,255,.35); }
.switch input:checked + .track::after { left: 21px; background: var(--primary); }

.week-box { display: flex; gap: 8px; flex-wrap: wrap; }
.week-box label {
  padding: 5px 12px; border-radius: 6px;
  background: #0f1729; border: 1px solid var(--border-2);
  cursor: pointer; font-size: 13px; color: var(--text-2);
}
.week-box input { display: none; }
.week-box input:checked + span { color: var(--primary); }
.week-box label:has(input:checked) { border-color: var(--primary); background: rgba(79,157,255,.1); }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.filter-bar .input, .filter-bar .select { width: auto; min-width: 150px; padding: 7px 11px; }

/* ---------- 分页 ---------- */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-3); flex-wrap: wrap; gap: 10px;
}
.pager-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.pager-btns a, .pager-btns span {
  min-width: 32px; height: 32px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; background: #1a2440; color: var(--text-2); font-size: 13px;
}
.pager-btns a:hover { background: #24314f; color: var(--text); opacity: 1; }
.pager-btns span.on { background: var(--primary); color: #fff; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(79,157,255,.13), transparent 60%),
    radial-gradient(700px 400px at 85% 85%, rgba(55,201,138,.09), transparent 60%),
    #0b1220;
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 400px;
  background: #131c32;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 34px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.login-box .brand { text-align: center; margin-bottom: 30px; }
.login-box .brand h1 { font-size: 23px; letter-spacing: 2px; }
.login-box .brand h1 em { color: var(--primary); font-style: normal; }
.login-box .brand p { font-size: 12px; color: var(--text-3); margin-top: 7px; letter-spacing: 1px; }
.login-box .input { padding: 12px 14px; font-size: 14px; }
.login-submit {
  width: 100%; padding: 13px; margin-top: 8px;
  border: none; border-radius: 9px; cursor: pointer;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; font-size: 15px; letter-spacing: 2px;
  transition: .2s;
}
.login-submit:hover { filter: brightness(1.1); }
.login-submit:disabled { opacity: .6; cursor: not-allowed; }
.captcha-row { display: flex; gap: 10px; }
.captcha-row .input { flex: 1; }
.captcha-box {
  min-width: 108px; display: flex; align-items: center; justify-content: center;
  background: #0f1729; border: 1px solid var(--border-2); border-radius: 8px;
  font-size: 16px; font-weight: 700; letter-spacing: 2px; color: var(--primary);
  cursor: pointer; user-select: none;
}

/* ---------- 提示 ---------- */
.toast-wrap {
  position: fixed; top: 22px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.toast {
  padding: 11px 22px; border-radius: 9px; font-size: 13px;
  background: #1e2a42; border: 1px solid var(--border-2); color: var(--text);
  box-shadow: 0 12px 30px rgba(0,0,0,.45);
  animation: toastIn .22s ease;
  max-width: 80vw;
}
.toast.success { border-color: rgba(55,201,138,.4); color: var(--success); }
.toast.error { border-color: rgba(255,107,107,.4); color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.mask {
  position: fixed; inset: 0; background: rgba(5,9,17,.7);
  display: none; align-items: center; justify-content: center; z-index: 9998;
  backdrop-filter: blur(3px);
}
.mask.show { display: flex; }
.dialog {
  width: 92%; max-width: 400px;
  background: #16203a; border: 1px solid var(--border-2);
  border-radius: 13px; padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
}
.dialog h4 { font-size: 16px; margin-bottom: 10px; }
.dialog p { font-size: 13px; color: var(--text-2); line-height: 1.8; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ---------- 其他 ---------- */
.alert {
  padding: 12px 16px; border-radius: 8px; font-size: 13px; line-height: 1.8;
  margin-bottom: 16px; border-left: 3px solid var(--primary);
  background: rgba(79,157,255,.08); color: var(--text-2);
}
.alert.warn { border-color: var(--warn); background: rgba(240,180,41,.08); }
.alert.danger { border-color: var(--danger); background: rgba(255,107,107,.08); }
.alert.success { border-color: var(--success); background: rgba(55,201,138,.08); }
.alert code, code {
  background: #0f1729; padding: 2px 6px; border-radius: 4px;
  color: var(--warn); font-size: 12px; font-family: Consolas, Monaco, monospace;
}

.progress {
  height: 8px; border-radius: 6px; background: #1a2440; overflow: hidden; margin: 14px 0;
}
.progress .bar {
  height: 100%; width: 0; border-radius: 6px;
  background: linear-gradient(90deg, var(--primary), var(--success));
  transition: width .3s;
}

.log-pre {
  background: #0b1220; border: 1px solid var(--border);
  border-radius: 8px; padding: 14px; font-family: Consolas, Monaco, monospace;
  font-size: 12px; color: var(--text-2); line-height: 1.9;
  max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}

.mono { font-family: Consolas, Monaco, monospace; }
.text-muted { color: var(--text-3); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-0 { margin-top: 0; } .mt-10 { margin-top: 10px; } .mt-16 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-10 { margin-bottom: 10px; }
.flex { display: flex; } .between { justify-content: space-between; } .gap-10 { gap: 10px; }
.items-center { align-items: center; }

.channel-tip { font-size: 12px; color: var(--text-3); }
.chart-box { display: flex; align-items: flex-end; gap: 14px; height: 150px; padding: 10px 4px 0; }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.chart-bar i {
  display: block; width: 100%; max-width: 44px; border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--primary), rgba(79,157,255,.18));
  min-height: 3px;
}
.chart-bar span { font-size: 11px; color: var(--text-3); }
.chart-bar em { font-size: 11px; color: var(--text-2); font-style: normal; }

/* ==================== 系统 LOGO ==================== */
.sidebar .logo img.logo-img {
  height: 26px; max-width: 132px; object-fit: contain; display: block;
}

.login-box .brand img.login-logo {
  max-height: 56px; max-width: 210px; margin: 0 auto 12px;
  object-fit: contain; display: block;
}

.logo-upload { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }

.logo-preview {
  width: 92px; height: 92px; flex: 0 0 92px;
  border: 1px dashed var(--border-2); border-radius: 12px;
  background: #0f1729; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; transition: border-color .18s, background .18s;
}
.logo-preview:hover { border-color: var(--primary); }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.logo-preview .logo-empty { font-size: 12px; color: var(--text-3); }
.logo-preview.drag { border-color: var(--primary); background: rgba(79,157,255,.1); }
.logo-preview.loading { opacity: .55; pointer-events: none; }

.logo-actions { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 10px; }
.logo-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.logo-actions .tip { font-size: 12px; line-height: 1.7; color: var(--text-3); }

/* ==================== 门童驱动 ==================== */
.drv-pane { display: none; }
.drv-pane.on { display: block; }

.drv-test {
  margin-top: 18px; padding-top: 18px;
  border-top: 1px dashed var(--border);
}

.drv-btns { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }

.tip.ok-text { color: var(--success); }
.tip.warn-text { color: var(--warn); }
#drvResult:empty { display: none; }

@media (max-width: 900px) {
  .sidebar { width: 62px; }
  .sidebar .logo span, .nav-item span:last-child, .sidebar-foot { display: none; }
  .sidebar .logo img.logo-img { max-width: 34px; height: 22px; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .main { margin-left: 62px; }
  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* ---------- 门童配置模板 ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.tpl-card { border: 1px solid #1f2b45; border-radius: 10px; padding: 16px; background: #151d2e; display: flex; flex-direction: column; gap: 8px; }
.tpl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-head b { font-size: 14px; font-weight: 600; }
.tpl-desc { font-size: 12px; color: var(--text-3); line-height: 1.7; min-height: 34px; }
.tpl-meta { font-size: 12px; color: var(--text-2); border-top: 1px dashed #24324b; padding-top: 8px; }
.tpl-card .td-actions { margin-top: auto; padding-top: 4px; }
.chk-list { display: flex; flex-direction: column; gap: 8px; max-height: 190px; overflow: auto; padding: 10px 12px; border: 1px solid #1f2b45; border-radius: 8px; background: #0f1626; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; color: var(--text-2); }
.chk input { accent-color: var(--primary); }
