:root {
  --admin-bg: #eef2f7;
  --admin-sidebar: #0f1b2d;
  --admin-sidebar-2: #16233a;
  --panel: #ffffff;
  --line: #e6ebf2;
  --text: #1f2a37;
  --muted: #6b7280;
  --blue: #0082ef;
  --blue-dark: #006fd1;
  --blue-soft: #e8f3ff;
  --ok: #0a7a45;
  --ok-bg: #e8f8ef;
  --err: #c93545;
  --err-bg: #ffecee;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body.admin-body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(80% 50% at 100% 0%, rgba(0, 130, 239, 0.08), transparent 55%),
    var(--admin-bg);
  min-height: 100vh;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, background .12s ease, opacity .12s ease;
}

.btn:active { transform: scale(.98); }

.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #1a8ff5, var(--blue));
  box-shadow: 0 8px 18px rgba(0, 130, 239, .25);
}

.btn-primary:hover { background: var(--blue-dark); }

.btn-secondary {
  color: var(--blue-dark);
  background: var(--blue-soft);
  border: 1px solid rgba(0, 130, 239, .12);
}

.btn-danger {
  color: #fff;
  background: #e34d59;
}

.btn-sm { min-height: 34px; padding: 0 12px; font-size: 12px; border-radius: 8px; }
.btn-xs { min-height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; width: auto; }

.field {
  display: grid;
  gap: 8px;
  margin: 0;
}

.field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #fbfcfe;
  outline: none;
  font: inherit;
}

.field input:focus {
  border-color: rgba(0, 130, 239, .55);
  box-shadow: 0 0 0 3px rgba(0, 130, 239, .12);
}

.field.compact { gap: 6px; }
.field.compact input { min-height: 36px; }
.field.full { grid-column: 1 / -1; }

/* login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: min(100%, 420px);
  background: var(--panel);
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.8);
  box-shadow: var(--shadow);
  padding: 28px 22px;
}

.login-brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 22px;
}

.login-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  background: linear-gradient(145deg, #1a8ff5, #0068c9);
  box-shadow: 0 10px 20px rgba(0, 130, 239, .28);
}

.login-logo.sm {
  width: 38px;
  height: 38px;
  font-size: 16px;
  border-radius: 11px;
}

.login-eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  color: var(--blue-dark);
  font-weight: 600;
}

.login-card h1 {
  margin: 0;
  font-size: 24px;
}

.login-form { display: grid; gap: 14px; }
.login-foot {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* shell */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--admin-sidebar), var(--admin-sidebar-2));
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sidebar-brand strong {
  display: block;
  font-size: 15px;
}

.sidebar-brand span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255,255,255,.55);
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-link {
  color: rgba(255,255,255,.78);
  text-decoration: none;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
}

.side-link.active,
.side-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

.side-logout {
  margin-top: auto;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  font-size: 13px;
  padding: 10px 12px;
}

.side-logout:hover { color: #fff; }

.shell-main {
  padding: 24px 22px calc(32px + var(--safe-bottom));
  width: min(100%, 1180px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 26px;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}

.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--err-bg); color: var(--err); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 28px;
  letter-spacing: .02em;
}

.workspace {
  display: grid;
  gap: 16px;
}

.workspace.has-editor {
  grid-template-columns: 1fr 1.15fr;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.panel-head.tight { margin-bottom: 10px; }

.panel-head h2,
.panel-head h3 {
  margin: 0;
  font-size: 17px;
}

.panel-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.channel-list {
  display: grid;
  gap: 12px;
}

.channel-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fbfcfe;
}

.channel-card.active {
  border-color: rgba(0, 130, 239, .45);
  background: linear-gradient(180deg, #f3f9ff, #fff);
  box-shadow: 0 0 0 3px rgba(0, 130, 239, .06);
}

.channel-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.channel-top h3 {
  margin: 0;
  font-size: 16px;
}

.channel-link {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

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

.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef1f5;
  color: var(--muted);
}

.badge.on { background: var(--ok-bg); color: var(--ok); }
.badge.off { background: #f1f1f1; color: #999; }
.badge.blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge.gray { background: #eef1f5; color: #667085; }

.channel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.empty-box {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fafbfc;
}

.empty-box.soft { padding: 18px; margin-bottom: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.divert-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #f8fbff;
  margin-bottom: 16px;
}

.divert-box h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.divert-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.radio-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
}

.radio-card input { margin-top: 3px; accent-color: var(--blue); }

.radio-card strong {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
}

.radio-card span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.switch-line {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  margin-top: 8px;
}

.switch-line input { accent-color: var(--blue); }

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

.image-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.image-card.disabled { opacity: .55; }

.image-thumb {
  aspect-ratio: 1;
  background: #f5f7fa;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #fff;
}

.image-meta { padding: 10px; }

.image-meta .hit {
  margin: 6px 0 8px;
  font-size: 12px;
  color: var(--muted);
}

.image-ops {
  display: flex;
  gap: 8px;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 16px;
}

.upload-form {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.upload-row {
  display: flex;
  gap: 10px;
  align-items: end;
  margin-bottom: 8px;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 10px;
  background: linear-gradient(180deg, #1a8ff5, var(--blue));
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 130, 239, .22);
}

.upload-btn.grow { flex: 1; }

.danger-zone {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed #f0c7cb;
}

.hidden-form { display: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  background: rgba(26, 26, 26, .9);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
  }
  .side-nav { display: flex; gap: 8px; }
  .side-logout { margin-top: 0; margin-left: auto; }
  .workspace.has-editor { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid,
  .divert-row,
  .image-grid { grid-template-columns: 1fr; }
  .shell-main { padding: 16px 14px 28px; }
  .topbar { flex-direction: column; }
}
