:root {
  --bg: #f5f7f4;
  --panel: #fff;
  --line: #dfe5df;
  --line-strong: #cad3ca;
  --text: #202a24;
  --muted: #718077;
  --accent: #f06424;
  --accent-soft: #fff0e7;
  --green: #16896a;
  --green-soft: #e7f6f1;
  --red: #cf4b45;
  --red-soft: #fdeceb;
  --blue: #2f69b3;
  --blue-soft: #eaf2fd;
  --amber: #a26a08;
  --amber-soft: #fdf3e2;
  --radius: 8px;
  font-family: "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 13px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
code { font-family: Consolas, "Courier New", monospace; }

/* ── 品牌与头部 ─────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 11px; }
.brand.centered { justify-content: center; margin-bottom: 18px; color: var(--text); }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px;
  border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800;
}
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; font-size: 11px; color: var(--muted); }

.p-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--panel);
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px;
  border-radius: 6px; background: #eef1ef; color: var(--muted); font-size: 11px; white-space: nowrap;
}
.chip.accent { color: #c64b16; background: var(--accent-soft); }
.chip.green { color: var(--green); background: var(--green-soft); }
.chip.red { color: var(--red); background: var(--red-soft); }

.tabs { display: flex; gap: 4px; padding: 0 22px; border-bottom: 1px solid var(--line); background: var(--panel); }
.tab {
  min-height: 40px; padding: 0 14px; border: 0; border-bottom: 2px solid transparent;
  background: transparent; color: var(--muted); font-size: 13px;
}
.tab:hover { color: var(--text); }
.tab.active { border-bottom-color: var(--accent); color: var(--text); font-weight: 600; }

.p-main { min-width: 0; padding: 20px 22px 44px; }

/* 页签切换：默认全部隐藏，只有 active 的那个显示 */
.view { display: none; }
.view.active { display: block; }

/* ── 通用控件 ──────────────────────────────────────────────── */
.btn {
  min-height: 34px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 7px;
  background: #fff; color: var(--text); font-size: 12px;
}
.btn:hover { border-color: var(--accent); color: #c64b16; }
.btn.primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn.primary:hover { background: #d95518; color: #fff; }
.btn.danger { border-color: #e8b5b2; color: var(--red); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line-strong); color: var(--text); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.row-actions .btn { min-height: 27px; padding: 0 8px; font-size: 11px; }

input, select, textarea {
  width: 100%; min-height: 36px; padding: 0 10px; border: 1px solid var(--line-strong);
  border-radius: 6px; outline: none; background: #fff; color: var(--text);
}
textarea { min-height: 84px; padding: 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,100,36,.1); }
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.filters select { width: auto; min-width: 150px; }

/* ── 面板与指标 ────────────────────────────────────────────── */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin-bottom: 16px; }
.metrics article, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.metrics article { padding: 15px; }
.metrics span, .metrics small { display: block; color: var(--muted); font-size: 11px; }
.metrics strong { display: block; margin: 10px 0 7px; font-size: 21px; }
.metrics strong em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 400; }
.panel { padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 7px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 9px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f7f9f6; color: var(--muted); white-space: nowrap; font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td code, .mono { padding: 2px 5px; border-radius: 4px; background: #f1f4f1; font-family: Consolas, monospace; }

.badge { display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px; border-radius: 5px; font-size: 11px; }
.badge.green { color: var(--green); background: var(--green-soft); }
.badge.red { color: var(--red); background: var(--red-soft); }
.badge.blue { color: var(--blue); background: var(--blue-soft); }
.badge.amber { color: var(--amber); background: var(--amber-soft); }
.badge.gray { color: var(--muted); background: #eef1ef; }

/* 权益清单：一格一项，标签在上一行、值在下一行，长文案也不会互相挤 */
.rights { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.rights div {
  display: grid; gap: 4px;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfa; font-size: 12px;
}
.rights div span { color: var(--muted); font-size: 11px; }
.rights div strong { font-size: 13px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.pager span { margin-right: auto; }
.muted-text { color: var(--muted); }
.small { font-size: 11px; line-height: 1.7; }

/* 领卡结果：明文码只显示这一次，做成醒目的一次性区块 */
.issued { margin-top: 16px; padding: 14px; border: 1px solid #e9c98c; border-radius: var(--radius); background: #fffaf0; }
.issued-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.issued-head h3 { margin: 0; font-size: 14px; }
.issued-list { display: grid; gap: 4px; max-height: 300px; overflow: auto; }
.issued-list code { display: block; padding: 7px 9px; border-radius: 5px; background: #fff; font-size: 12px; }

.empty-cell { padding: 18px 11px; color: var(--muted); text-align: center; }
.empty-state { display: grid; gap: 6px; padding: 16px; border: 1px dashed var(--line-strong); border-radius: 7px; background: #fbfcfa; color: var(--muted); font-size: 12px; }
.empty-state strong { color: var(--text); font-size: 13px; }

/* ── 登录与浮层 ────────────────────────────────────────────── */
.login-overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(22,30,25,.62); backdrop-filter: blur(5px); }
.login-overlay.hidden { display: none; }
.login-card { width: min(420px, calc(100vw - 30px)); padding: 24px; border-radius: 10px; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.login-card label { display: block; margin-bottom: 12px; }
.login-card .btn { width: 100%; margin-top: 6px; }
.login-error { min-height: 18px; margin: 9px 0 0; color: var(--red); font-size: 12px; text-align: center; }

.modal { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px; background: rgba(22,30,25,.55); }
.modal.hidden { display: none; }
.modal-card { width: min(560px, 100%); max-height: 88vh; overflow: auto; border-radius: 10px; background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; white-space: pre-wrap; }
.icon-button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.modal-body { padding: 18px; }
.modal-body label { display: block; margin-bottom: 12px; }
.ask-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 50; max-width: 420px;
  padding: 11px 14px; border-radius: 7px; background: #26332b; color: #fff;
  opacity: 0; transform: translateY(10px); pointer-events: none; transition: .16s; font-size: 12px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #7d2c28; }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .p-main { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .p-header { flex-wrap: wrap; }
}
