* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, 'Helvetica Neue', sans-serif; background: #f0f2f5; color: #1a1a1a; height: 100vh; overflow: hidden; }

/* 登录页 */
.login-screen { position: fixed; inset: 0; background: #1e1e2e; display: flex; align-items: center; justify-content: center; z-index: 100; }
.login-card { background: #fff; border-radius: 16px; padding: 48px 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
body.stage-prod .login-card { border: 4px solid #c1272d; }
.login-logo-img { display: block; width: 220px; margin: 0 auto 24px; object-fit: contain; }
.login-title { text-align: center; font-size: 20px; font-weight: 700; color: #111; margin-bottom: 32px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input, .login-form select { padding: 12px 14px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; background: #fff; }
.login-form input:focus { outline: none; border-color: #c1272d; }
.login-form .btn-primary { padding: 12px; font-size: 15px; border-radius: 8px; margin-top: 4px; }
.login-env-warning { padding: 10px 12px; border-radius: 8px; background: #e3f2fd; color: #1565c0; font-size: 13px; font-weight: 700; text-align: center; }
body.stage-prod .login-env-warning { background: #fde8e8; color: #c1272d; }

/* Layout */
.layout { display: flex; height: 100vh; }

/* Sidebar */
.sidebar { width: 220px; min-width: 220px; background: #1e1e2e; display: flex; flex-direction: column; height: 100vh; }
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 24px 20px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-logo-icon { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; flex-shrink: 0; }
.logo-text { color: #fff; font-size: 16px; font-weight: 700; letter-spacing: 1px; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 20px; border: none; background: none; color: rgba(255,255,255,0.55); font-size: 14px; cursor: pointer; text-align: left; transition: all 0.15s; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-item.active { background: rgba(193,39,45,0.2); color: #fff; border-left-color: #c1272d; font-weight: 600; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* 侧边栏底部退出 */
.sidebar-bottom { padding: 16px; border-top: 1px solid rgba(255,255,255,0.07); }
.admin-env-badge { margin-bottom: 10px; padding: 8px 10px; border-radius: 8px; text-align: center; font-size: 12px; font-weight: 700; color: #fff; background: #1565c0; }
body.stage-prod .admin-env-badge { background: #c1272d; }
body.stage-prod .content { box-shadow: inset 0 6px 0 #c1272d; }
body.stage-prod .sidebar { background: #2b1517; }
.btn-logout { width: 100%; padding: 10px; background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; font-size: 13px; cursor: pointer; }
.btn-logout:hover { background: rgba(193,39,45,0.2); color: #fff; border-color: #c1272d; }

/* 配置表单 */
.cfg-group { padding: 18px 0; border-top: 1px solid #f0f0f0; }
.cfg-group:first-of-type { border-top: none; padding-top: 0; }
.cfg-group-title { font-size: 14px; font-weight: 700; color: #333; margin-bottom: 14px; }
.cfg-field { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.cfg-field label { width: 110px; min-width: 110px; font-size: 13px; color: #666; }
.cfg-field input { flex: 1; padding: 8px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; }
.cfg-field input:focus { outline: none; border-color: #c1272d; }
.cfg-hint { font-size: 12px; color: #aaa; margin-top: 8px; }
.cfg-switch { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #444; cursor: pointer; }
.cfg-switch input { width: 18px; height: 18px; accent-color: #c1272d; cursor: pointer; }

/* 奖项编辑器 */
.tier-editor-head { display: grid; grid-template-columns: 1fr 1fr 1fr 40px; gap: 10px; padding: 0 2px 8px; font-size: 12px; color: #999; font-weight: 600; }
.tier-edit-row { display: grid; grid-template-columns: 1fr 1fr 1fr 40px; gap: 10px; margin-bottom: 8px; align-items: center; }
.tier-edit-row input { padding: 8px 10px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; width: 100%; box-sizing: border-box; }
.tier-edit-row input:focus { outline: none; border-color: #c1272d; }
.tier-del { background: #fde8e8; color: #c1272d; border: none; border-radius: 8px; height: 36px; cursor: pointer; font-size: 16px; }
.tier-del:hover { background: #f9d0d0; }

.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-row { display: flex; align-items: center; gap: 16px; }
.settings-row label { width: 100px; min-width: 100px; font-size: 14px; color: #555; font-weight: 500; }
.settings-row input { flex: 1; padding: 9px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; }
.settings-row input[readonly] { background: #f5f5f5; font-weight: 700; }
.settings-row input:focus { outline: none; border-color: #c1272d; }

/* Content */
.content { flex: 1; overflow-y: auto; padding: 32px; }
.tab { display: none; }
.tab.active { display: block; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: #111; }
.btn-group { display: flex; gap: 8px; }
.config-actions { align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.config-action-msg { min-height: 0; margin: 0 0 0 4px; line-height: 36px; }

/* Cards */
.card { background: #fff; border-radius: 12px; padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.card-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.card-title { font-size: 13px; font-weight: 600; color: #888; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 16px; }
.card-desc { font-size: 13px; color: #999; margin-bottom: 16px; line-height: 1.6; }

/* Stat cards */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.stat-card .label { font-size: 12px; color: #999; margin-bottom: 8px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: #111; }

/* Buttons */
button { cursor: pointer; border: none; border-radius: 8px; font-size: 14px; font-weight: 600; transition: opacity 0.15s; }
.btn-primary { background: #c1272d; color: #fff; padding: 9px 18px; }
.btn-primary:hover { opacity: 0.88; }
.btn-secondary { background: #f0f2f5; color: #444; padding: 9px 18px; }
.btn-secondary:hover { background: #e4e6ea; }
.btn-danger { background: #fde8e8; color: #c1272d; padding: 9px 18px; }
.btn-danger:hover { background: #f9d0d0; }

/* Forms */
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.form-row input { flex: 1; min-width: 160px; padding: 9px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; }
.form-row input:focus { outline: none; border-color: #c1272d; }
textarea { width: 100%; padding: 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-family: 'Menlo', monospace; font-size: 13px; resize: vertical; }
textarea:focus { outline: none; border-color: #c1272d; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.modal-box { position: relative; background: #fff; border-radius: 14px; width: 90%; max-width: 900px; max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid #f0f0f0; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: #f5f5f5; border: none; width: 32px; height: 32px; border-radius: 50%; font-size: 14px; cursor: pointer; color: #666; }
.modal-close:hover { background: #eee; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.modal-pagination { display: flex; align-items: center; justify-content: space-between; padding-top: 16px; border-top: 1px solid #f0f0f0; margin-top: 16px; font-size: 13px; color: #888; }
.modal-pagination .btn-group { display: flex; gap: 8px; }

/* Batch table */
.batch-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.batch-table th { text-align: left; padding: 10px 12px; color: #888; font-weight: 600; font-size: 12px; border-bottom: 2px solid #f0f0f0; }
.batch-table td { padding: 12px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
.batch-table tr:last-child td { border-bottom: none; }
.batch-table tr:hover td { background: #fafafa; }
.batch-id { font-family: monospace; font-weight: 600; color: #333; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-used { background: #e8f5e9; color: #2e7d32; }
.badge-unused { background: #e3f2fd; color: #1565c0; }
.badge-fail { background: #fde8e8; color: #c1272d; }
.badge-processing { background: #fff4e0; color: #d97706; }
.batch-actions { display: flex; gap: 6px; }
.batch-actions button { padding: 5px 10px; font-size: 12px; }

/* Audit logs */
.audit-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.audit-filters label { display: flex; flex-direction: column; gap: 7px; color: #666; font-size: 12px; font-weight: 600; }
.audit-filters input, .audit-filters select { width: 100%; padding: 9px 12px; border: 1px solid #e0e0e0; border-radius: 8px; background: #fff; color: #333; font-size: 14px; }
.audit-filters input:focus, .audit-filters select:focus { outline: none; border-color: #c1272d; }
.audit-filter-actions { margin-top: 18px; }
.audit-table-wrap { width: 100%; overflow-x: auto; }
.audit-table { min-width: 1080px; }
.audit-table td { vertical-align: top; }
.audit-time { white-space: nowrap; }
.audit-details { min-width: 260px; max-width: 420px; max-height: 160px; margin: 0; padding: 8px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; }
.audit-pagination { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; margin-top: 16px; border-top: 1px solid #f0f0f0; color: #888; font-size: 13px; }
.audit-pagination .batch-select { min-width: 88px; padding: 6px 10px; }

@media (max-width: 760px) {
  .sidebar { width: 180px; min-width: 180px; }
  .content { padding: 20px; }
  .audit-pagination { align-items: flex-start; flex-direction: column; }
}

/* Failed list */
.failed-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f0f0f0; }
.failed-item:last-child { border-bottom: none; }
.failed-code { font-family: monospace; flex: 1; font-size: 13px; color: #333; }
.failed-status { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.failed-status.fail { background: #fde8e8; color: #c1272d; }
.failed-status.processing { background: #fff4e0; color: #d97706; }
.failed-item button { padding: 5px 14px; font-size: 13px; }
.empty { color: #bbb; font-size: 14px; padding: 16px 0; }

/* Batch select */
.batch-select { padding: 9px 12px; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; background: #fff; color: #333; cursor: pointer; min-width: 160px; }
.batch-select:focus { outline: none; border-color: #c1272d; }

/* Tier chart */
.tier-chart { display: flex; align-items: stretch; justify-content: center; gap: 18px; min-height: 246px; padding: 8px 8px 0; overflow-x: auto; border-bottom: 1px solid #e8e8e8; }
.tier-column { display: flex; flex: 1 0 72px; flex-direction: column; align-items: center; max-width: 150px; }
.tier-plot { display: flex; flex: 1; width: 100%; min-height: 212px; flex-direction: column; align-items: center; justify-content: flex-end; }
.tier-label { display: flex; min-height: 34px; align-items: center; justify-content: center; padding-top: 8px; color: #555; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tier-bar { width: min(62px, 72%); flex-shrink: 0; border-radius: 7px 7px 0 0; background: linear-gradient(180deg, #df4d52 0%, #c1272d 100%); box-shadow: 0 4px 12px rgba(193,39,45,0.18); transition: height 0.4s ease; }
.tier-count { margin-bottom: 6px; color: #555; font-size: 13px; font-weight: 700; line-height: 18px; }

/* Misc */
pre { background: #f7f8fa; padding: 16px; border-radius: 8px; overflow: auto; font-size: 13px; color: #333; }
.msg { margin-top: 10px; font-size: 13px; color: #c1272d; min-height: 18px; }
.muted { color: #999; }
