:root {
  --bg-paper: #FAF6EE;
  --card-white: #FFFDF8;
  --ink: #1C1B18;
  --muted: #666156;
  --primary: #F7C948;
  --ssr: #F26430;
  --success: #25A267;
  --border: 2px solid #1C1B18;
  --shadow: 4px 4px 0 #1C1B18;
  --shadow-sm: 2px 2px 0 #1C1B18;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-paper);
  background-image: radial-gradient(rgba(28, 27, 24, 0.08) 1px, transparent 1px);
  background-size: 18px 18px;
  color: var(--ink);
  min-height: 100vh;
}

.hidden { display: none !important; }

.preview-banner {
  position: sticky;
  top: 0;
  z-index: 999;
  width: 100%;
  padding: 10px 16px;
  text-align: center;
  background: #F26430;
  color: #FFFDF8;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #1C1B18;
}

.paper-card {
  background: var(--card-white);
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box { width: 100%; max-width: 440px; }
.brand-badge {
  display: inline-block;
  background: var(--primary);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 4px 10px;
  font-weight: 800;
  font-size: 12px;
  border-radius: 999px;
}
.login-title { margin: 14px 0 6px; font-size: 26px; }
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 244px;
  background: #F4ECDD;
  border-right: var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex-shrink: 0;
}

.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px; }
.logo-stamp {
  width: 44px; height: 44px;
  background: var(--primary);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 900; font-size: 22px;
  transform: rotate(-4deg);
}
.brand-name { font-weight: 900; font-size: 17px; }
.brand-tag { font-size: 12px; color: var(--muted); }

.nav-menu { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.nav-item {
  width: 100%; text-align: left; cursor: pointer;
  background: var(--card-white);
  border: var(--border); border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px; font-weight: 700; color: var(--ink);
  display: flex; align-items: center; gap: 10px;
  transition: transform 0.1s ease, background 0.1s ease;
}
.nav-item:hover { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.nav-item.active { background: var(--primary); box-shadow: var(--shadow-sm); }

.sidebar-footer { display: flex; flex-direction: column; gap: 10px; }
.env-pill {
  font-size: 12px; padding: 6px 10px; border-radius: 8px;
  background: #E9F7EF; border: var(--border); color: var(--ink);
  word-break: break-all;
}

.main-area { flex: 1; padding: 24px 28px; max-width: 1360px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.page-title { margin: 0; font-size: 24px; }
.page-subtitle { margin: 4px 0 0; font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.btn {
  border: var(--border); border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 800;
  cursor: pointer; background: var(--card-white); color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease;
}
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); color: #FFF; }
.btn-danger { background: var(--ssr); color: #FFF; }
.btn-ghost { background: var(--card-white); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }

.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { padding: 16px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 700; }
.stat-value { font-size: 30px; font-weight: 900; margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }

.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; }
.field input, .field select, .field textarea {
  border: var(--border); border-radius: 8px;
  padding: 9px 11px; font-size: 14px; background: #FFF; color: var(--ink);
  font-family: inherit;
}
.field textarea { min-height: 76px; resize: vertical; }

.switch-row { display: flex; flex-wrap: wrap; gap: 12px; padding: 6px 0; }
.switch-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-paper); border: var(--border);
  border-radius: 999px; padding: 5px 11px; font-size: 12px; font-weight: 700;
  cursor: pointer;
}

.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  border: 1.5px solid var(--ink); font-size: 12px; font-weight: 800;
}
.badge-on { background: var(--success); color: #FFF; }
.badge-off { background: #E5DFD2; color: var(--ink); }
.badge-ssr { background: var(--ssr); color: #FFF; }
.badge-sr { background: #FFAB40; color: var(--ink); }
.badge-r { background: var(--primary); color: var(--ink); }
.badge-n { background: #ECE6D9; color: var(--ink); }

.guide-note {
  background: #FFF9E6; border: 1.5px dashed var(--ink);
  border-radius: 8px; padding: 10px 12px; font-size: 12px; line-height: 1.6;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1.5px solid #DDD5C4; padding: 10px 8px; text-align: left; }
th { font-weight: 900; background: #F4ECDD; }

.thumb-img {
  width: 48px; height: 48px; object-fit: cover;
  border: 1.5px solid var(--ink); border-radius: 6px; background: var(--bg-paper);
}

.error-banner {
  margin-top: 12px; padding: 10px 12px; border-radius: 8px;
  background: #FFE5DC; border: var(--border); color: #A82700; font-size: 13px; font-weight: 700;
}
.advanced-box { font-size: 12px; color: var(--muted); }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(28, 27, 24, 0.52);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-box { width: 100%; max-width: 680px; max-height: 88vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 18px; }

.toast-box {
  position: fixed; right: 20px; bottom: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  background: var(--ink); color: #FFF; border: var(--border);
  box-shadow: var(--shadow-sm); border-radius: 10px;
  padding: 10px 16px; font-size: 13px; font-weight: 700;
}
.toast-item.ok { background: var(--success); }
.toast-item.err { background: var(--ssr); }

.version-pill {
  display: inline-block;
  background: var(--card-white);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  padding: 4px 10px;
  font-weight: 800;
  font-size: 12px;
  border-radius: 999px;
  color: var(--ink);
}
.version-card {
  background: var(--card-white);
  border: var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: 10px;
  padding: 9px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.version-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.version-num { font-size: 13px; font-weight: 900; color: var(--ink); }
.ver-env-tag {
  font-size: 11px; font-weight: 800; padding: 2px 7px;
  border-radius: 999px; border: 1.5px solid var(--ink);
  background: #DDF6E7; color: #12613B;
}
.ver-env-tag.is-preview { background: #FFE2D6; color: #A82700; }
.version-meta { font-size: 11px; color: var(--muted); line-height: 1.4; word-break: break-all; }

@media (max-width: 820px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: var(--border); }
  .main-area { padding: 16px; }
}
