/* ============ 标签打印后台 · 基础 ============ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sidebar: #0f172a;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ============ 登录页 ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}
.login-card {
  width: 360px;
  background: var(--card);
  border-radius: 14px;
  padding: 32px 30px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.login-title { font-size: 18px; font-weight: 700; text-align: center; margin-bottom: 24px; }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 200px;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  padding: 18px 20px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: block;
  padding: 11px 20px;
  color: #cbd5e1;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: rgba(37, 99, 235, .25); color: #fff; border-left-color: var(--primary); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.admin-name { color: var(--muted); }

.content { padding: 24px; flex: 1; }

/* ============ 备案信息 ============ */
/* 登录页：深色渐变背景上使用半透明白字 */
.beian {
  margin-top: 16px;
  font-size: 12px;
  text-align: center;
  color: rgba(255, 255, 255, .65);
}
.beian a { color: inherit; text-decoration: none; }
.beian a:hover { text-decoration: underline; }

/* 后台页脚：内容区 flex:1 撑满后自然贴底 */
.app-footer {
  padding: 12px 24px;
  font-size: 12px;
  text-align: center;
  color: var(--muted);
}
.app-footer a { color: inherit; text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* ============ 卡片 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }

/* ============ 表单 ============ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-weight: 500; color: var(--text); font-size: 13px; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .3); border-color: var(--primary); }
textarea { resize: vertical; min-height: 60px; }
.upload-row { display: flex; gap: 8px; }
.upload-row input[type="text"], .upload-row input:not([type="file"]) { flex: 1; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

.form-error { color: var(--danger); min-height: 20px; font-size: 13px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: filter .12s, background .12s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.actions { white-space: nowrap; }
.actions .btn + .btn { margin-left: 8px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* ============ 徽章 ============ */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #e2e8f0; color: #475569; }

/* ============ 分页 ============ */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 14px 20px; }
.pagination span { color: var(--muted); font-size: 13px; }

/* ============ 弹窗 ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
  max-height: 84vh;
  overflow: auto;
}
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }

/* ============ Toast ============ */
.toast-root { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  padding: 12px 16px;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: slideIn .2s ease;
  max-width: 340px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: #0ea5e9; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ 其它 ============ */
.filter-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filter-bar .field { margin-bottom: 0; }
.filter-bar input, .filter-bar select { width: auto; min-width: 120px; }
.filter-bar input#f-batch, .filter-bar input#r-batch { min-width: 170px; }
.filter-bar input#f-code { min-width: 220px; }
/* 筛选栏内的输入框 / 下拉框 / 按钮统一等高对齐（按钮抵消 btn-sm 的矮小尺寸） */
.filter-bar input, .filter-bar select, .filter-bar .btn { height: 40px; }
.filter-bar .btn { padding: 8px 16px; font-size: 14px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px 0; }

/* ============ Tab 页签 ============ */
.tabs { display: flex; gap: 4px; align-items: center; margin-bottom: 14px; }
.tab {
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 8px 8px 0 0;
  background: #fff;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  border-bottom: none;
}
.tab.active { color: var(--primary); font-weight: 600; border-color: var(--primary); }
.tab-actions { margin-left: auto; display: flex; gap: 8px; }
.tabs + .card { border-radius: 0 8px 8px 8px; }

/* ============ 审计日志 ============ */
.nowrap { white-space: nowrap; }

/* 描述网格（弹窗元信息区） */
.desc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 28px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.desc-item { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.desc-label { font-size: 12px; color: var(--muted); }
.desc-value { font-size: 14px; color: var(--text); word-break: break-all; }

/* 弹窗小节标题 */
.modal-sec-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 18px 0 8px;
}

/* 大号弹窗 */
.modal-lg { max-width: 720px; }

/* JSON 语法高亮面板 */
.json-panel {
  border: 1px solid #1e293b;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
}
.json-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #1e293b;
  color: #94a3b8;
  font-size: 13px;
}
.json-panel-head .btn { background: transparent; border-color: #334155; color: #cbd5e1; }
.json-panel-head .btn:hover { background: #334155; }
.json-view {
  margin: 0;
  padding: 14px 16px;
  max-height: 320px;
  overflow: auto;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #e2e8f0;
  white-space: pre;
  word-break: normal;
}
.json-key { color: #93c5fd; }
.json-str { color: #86efac; }
.json-num { color: #fbbf24; }
.json-bool { color: #c084fc; }
.json-null { color: #94a3b8; font-style: italic; }

/* 无详情空态 */
.detail-empty {
  padding: 28px 0;
  text-align: center;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 8px;
  font-size: 13px;
}

/* ============ 兑换码展示 ============ */
.code-chip {
  font-family: Consolas, Monaco, monospace;
  font-size: 13px;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 2px 6px;
  color: #0f172a;
  user-select: all;
}
.code-box { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.code-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 6px; border-radius: 6px; }
.code-line:nth-child(odd) { background: #f8fafc; }
.code-line code { font-family: Consolas, Monaco, monospace; font-size: 14px; }

.error-text { color: var(--danger); font-weight: 600; }

.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar { width: 100%; max-width: 40px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s; }
.chart-bars-green .chart-bar { background: var(--success); }
.chart-date { font-size: 11px; color: var(--muted); transform: rotate(-30deg); }
/* 开关（iOS 风格） */
.switch-label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; flex-shrink: 0; }
.switch-label input { display: none; }
.switch-track { width: 44px; height: 24px; border-radius: 12px; background: var(--border); position: relative; transition: background .2s; flex-shrink: 0; }
.switch-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch-label input:checked + .switch-track { background: var(--primary); }
.switch-label input:checked + .switch-track::after { transform: translateX(20px); }
.switch-label:hover .switch-track { opacity: .9; }
