* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #0a0a0c; color: #f2f2f2; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { width: 360px; background: #16161a; padding: 40px; border-radius: 16px; }
.login-box h1 { font-size: 20px; margin-bottom: 24px; color: #e8b86d; }
.field { margin-bottom: 16px; }
.field label { display: block; color: #888; margin-bottom: 6px; font-size: 13px; }
input, select, textarea { width: 100%; background: #0f0f12; border: 1px solid #2a2a2e; border-radius: 8px; padding: 10px 12px; color: #fff; font-size: 14px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: #e8b86d; }
textarea { resize: vertical; }
button { cursor: pointer; border: none; border-radius: 8px; font-size: 14px; }
.btn-primary { width: 100%; background: linear-gradient(135deg, #e8b86d, #d49a4e); color: #1a1a1a; padding: 12px; font-weight: 600; }
.btn-small { background: #e8b86d; color: #1a1a1a; padding: 8px 16px; font-weight: 600; }
.btn-small.success { background: #6de89a; }
.btn-small.danger { background: #e86d6d; color: #fff; }
.muted { color: #888; font-size: 12px; }

/* 布局 */
.app { display: none; }
.topbar { background: #0d0d0f; padding: 14px 28px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #222; gap: 16px; flex-wrap: wrap; }
.topbar .logo { color: #e8b86d; font-weight: 700; font-size: 18px; white-space: nowrap; }
.topbar select { width: auto; background: #16161a; color: #e8b86d; border-radius: 8px; padding: 6px 10px; border: 1px solid #333; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { padding: 8px 18px; border-radius: 20px; color: #888; background: transparent; }
.tab.active { background: #e8b86d; color: #1a1a1a; font-weight: 600; }
.body { padding: 24px 28px; }
.toolbar { margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card { padding: 20px; border: 1px solid #292929; border-radius: 12px; background: #16161a; }
.card .num { font-size: 28px; font-weight: 700; color: #e8b86d; }
.card .label { color: #888; font-size: 13px; margin-top: 4px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid #222; font-size: 14px; }
th { color: #888; font-weight: 500; font-size: 13px; }
td img.thumb { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #222; }
.price { color: #e8b86d; font-weight: 600; }
.link { color: #e8b86d; cursor: pointer; margin-right: 12px; }
.link.danger { color: #e86d6d; }
.tag { padding: 3px 10px; border-radius: 12px; font-size: 12px; }
.tag.on { background: #1a3a24; color: #6de89a; }
.tag.off { background: #2a2a2a; color: #888; }
.pager { margin-top: 12px; display: flex; gap: 8px; align-items: center; }
.pager button { background: #16161a; color: #fff; border: 1px solid #333; padding: 6px 12px; }

/* 弹窗 */
.mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 10; align-items: center; justify-content: center; }
.modal { background: #16161a; border-radius: 16px; padding: 28px; width: 500px; max-height: 90vh; overflow: auto; }
.modal.media-modal { width: min(820px, calc(100vw - 32px)); }
.modal-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title-row h2 { font-size: 18px; }
.modal-close { width: 38px; height: 38px; border: 1px solid #3a3a3f; border-radius: 50%; background: transparent; color: #c9c9c9; font-size: 26px; line-height: 34px; }
.modal-close:hover { background: #29292e; color: #fff; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.image-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.image-actions input[type=file] { width: auto; padding: 6px; }
.image-preview-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.image-preview-list img { width: 80px; height: 80px; border-radius: 8px; object-fit: cover; background: #222; }
.image-preview-list .img-wrap { position: relative; }
.image-preview-list .img-x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; background: #e86d6d; color: #fff; border-radius: 50%; font-size: 12px; line-height: 18px; text-align: center; cursor: pointer; }

/* 图片库 */
.media-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.media-toolbar input[type=file] { width: auto; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 14px; max-height: 60vh; overflow: auto; }
.media-item { padding: 8px; border: 1px solid #2e2e34; border-radius: 12px; background: #111114; cursor: pointer; }
.media-item:hover { border-color: #e8b86d; }
.media-item img { width: 100%; aspect-ratio: 1; border-radius: 8px; object-fit: cover; background: #222; }

/* 模版列表 + 编辑器 */
.tpl-list { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.tpl-card { border: 1px solid #2e2e34; border-radius: 12px; padding: 16px; background: #111114; min-width: 180px; cursor: pointer; }
.tpl-card.active { border-color: #e8b86d; }
.tpl-card .tpl-name { font-weight: 600; margin-bottom: 8px; }
.tpl-card .tpl-tag { font-size: 12px; color: #e8b86d; }
.tpl-card .tpl-ops { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.tpl-card .tpl-ops button { background: #222; color: #fff; padding: 5px 10px; font-size: 12px; }
.editor { border-top: 1px solid #222; padding-top: 18px; }
.editor-main { display: grid; grid-template-columns: 160px 1fr 280px; gap: 16px; }
.editor-palette { border: 1px solid #2e2e34; border-radius: 12px; padding: 12px; background: #111114; }
.palette-title { color: #888; font-size: 13px; margin-bottom: 10px; }
.palette-item { display: block; width: 100%; text-align: left; background: #1c1c20; color: #fff; padding: 10px; margin-bottom: 8px; border: 1px solid #2e2e34; }
.palette-item:hover { border-color: #e8b86d; }
.editor-canvas { border: 1px dashed #4c514e; border-radius: 12px; padding: 14px; min-height: 300px; background: #111714; }
.module-card { border: 1px solid #2e2e34; border-radius: 10px; padding: 12px; margin-bottom: 10px; background: #16161a; display: flex; align-items: center; gap: 12px; cursor: grab; }
.module-card .drag { color: #666; font-size: 18px; }
.module-card .m-info { flex: 1; }
.module-card .m-type { font-weight: 600; color: #e8b86d; }
.module-card .m-sum { color: #888; font-size: 12px; margin-top: 4px; }
.module-card .m-ops button { background: #222; color: #fff; padding: 5px 10px; font-size: 12px; margin-left: 6px; }
.editor-config { border: 1px solid #2e2e34; border-radius: 12px; padding: 14px; background: #111114; }
.editor-config .field { margin-bottom: 12px; }
.editor-config .cfg-img-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.editor-config .cfg-img-row input { flex: 1; }

.form-box { background: #16161a; border: 1px solid #292929; border-radius: 12px; padding: 20px; max-width: 480px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.form-box label { color: #888; font-size: 13px; }

.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #e8b86d; color: #1a1a1a; padding: 10px 24px; border-radius: 20px; display: none; z-index: 99; font-weight: 600; }
