/* 管理后台样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --brown: #7a5230; --brown-d: #5d3f24; --bg: #f5f1ea; --line: #e8dfd1;
  --ink: #33291f; --ink2: #8a7d6d; --green: #3d8a5a; --red: #c0453a;
}
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--ink); }
button { font-family: inherit; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(150deg,#5d7a45,#2e4423); }
.login-box { background: #fffdf9; border-radius: 18px; padding: 40px 36px; width: 340px; text-align: center; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-logo { font-size: 40px; }
.login-box h1 { font-size: 20px; margin: 10px 0 4px; }
.login-box p { font-size: 13px; color: var(--ink2); margin-bottom: 22px; }
.login-box input { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 12px; font-size: 14px; background: #fbf8f2; }
.login-box input:focus { outline: 2px solid #d8c6a8; }
.login-box button { width: 100%; padding: 12px; background: var(--brown); color: #fff; border: none; border-radius: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: var(--brown-d); }
.login-err { color: var(--red); font-size: 13px; margin-top: 10px; min-height: 18px; }

/* hidden 属性优先于 display 布局（修复登录页/后台视图无法隐藏的问题） */
#loginView[hidden], #adminView[hidden] { display: none; }

/* 布局 */
#adminView { display: flex; min-height: 100vh; }
.side { width: 208px; flex: none; background: #2f2418; color: #e9ddc9; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.side-brand { padding: 22px 20px 18px; font-size: 17px; font-weight: 700; border-bottom: 1px solid #463724; }
.side-brand span { display: block; font-size: 11px; font-weight: 400; color: #a08d70; margin-top: 3px; }
#nav { flex: 1; padding: 12px 10px; }
#nav a { display: block; padding: 11px 14px; border-radius: 10px; color: #cdbd9f; font-size: 14px; cursor: pointer; margin-bottom: 4px; }
#nav a:hover { background: #3d2f1e; }
#nav a.on { background: var(--brown); color: #fff; font-weight: 600; }
.logout { margin: 14px; padding: 10px; background: none; border: 1px solid #55432c; color: #a08d70; border-radius: 10px; cursor: pointer; font-size: 13px; }
.logout:hover { color: #fff; border-color: #8a7350; }
#main { flex: 1; padding: 26px 30px; max-width: 1180px; }

.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: 13px; color: var(--ink2); margin-bottom: 20px; }

/* 卡片 & 表格 */
.panel { background: #fffdf9; border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; }
.stat-card { background: #fffdf9; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.stat-card b { font-size: 28px; color: var(--brown); display: block; }
.stat-card span { font-size: 13px; color: var(--ink2); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--ink2); font-weight: 600; font-size: 12.5px; padding: 8px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid #f0e9dc; vertical-align: middle; }
tr:hover td { background: #faf6ee; }
.mono { font-family: Menlo, "SF Mono", monospace; font-size: 12.5px; }

.btn { display: inline-block; border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--brown); color: #fff; }
.btn:hover { background: var(--brown-d); }
.btn-ghost { background: #f0e8d9; color: var(--brown); }
.btn-ghost:hover { background: #e6dac2; }
.btn-danger { background: none; color: var(--red); border: 1px solid #ecc9c5; }
.btn-danger:hover { background: #fdf0ee; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input { padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; background: #fff; }
.toolbar .sp { flex: 1; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.f-item label { display: block; font-size: 12.5px; color: var(--ink2); margin-bottom: 5px; }
.f-item input, .f-item select, .f-item textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13.5px; background: #fbf8f2; font-family: inherit;
}
.f-item textarea { resize: vertical; min-height: 70px; }
.f-item input:focus, .f-item textarea:focus, .f-item select:focus { outline: 2px solid #d8c6a8; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(40,30,18,.5); z-index: 60; display: flex; align-items: flex-start; justify-content: center; padding: 40px 20px; overflow-y: auto; }
.modal-mask[hidden] { display: none; }
.modal { background: #fffdf9; border-radius: 16px; padding: 24px; width: 100%; max-width: 560px; }
.modal h3 { font-size: 16.5px; margin-bottom: 16px; }
.modal .m-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* 图片上传 */
.img-list { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.img-list .thumb { position: relative; width: 72px; height: 72px; }
.img-list img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.img-list .del { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--red); color: #fff; border: none; font-size: 11px; cursor: pointer; line-height: 1; }
.upload-btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px dashed #c9b896; border-radius: 8px; color: var(--ink2); font-size: 12.5px; cursor: pointer; background: #fbf8f2; }

/* 阶段编辑 */
.stage-edit { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; background: #fdfaf4; }
.stage-edit .s-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.stage-edit .s-no { font-size: 11px; color: var(--ink2); letter-spacing: 1px; }
.stage-edit .s-name { font-weight: 700; font-size: 14.5px; }

/* 徽标 */
.badge { display: inline-block; background: #eef4ee; color: var(--green); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; margin: 1px 2px; }
.num-pos { color: var(--green); font-weight: 700; }

/* 二维码弹窗 */
.qr-modal { text-align: center; }
.qr-modal img { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 10px; }

/* 贴纸预览 */
.sticker-tip { font-size: 12.5px; color: var(--ink2); background: #fbf3e2; border: 1px solid #f0e0bd; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }

#toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 99; pointer-events: none; }
.toast-item { background: #33291f; color: #fff; padding: 10px 20px; border-radius: 10px; font-size: 13.5px; margin-bottom: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: tIn .2s; }
.toast-item.err { background: var(--red); }
@keyframes tIn { from { opacity: 0; transform: translateY(-8px); } }

.empty { text-align: center; color: var(--ink2); padding: 36px 0; font-size: 13.5px; }
@media (max-width: 860px) {
  #adminView { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; }
  #main { padding: 18px 14px; }
  .form-grid { grid-template-columns: 1fr; }
}
