:root {
  --bg: #f3eee6;
  --paper: #fffdf9;
  --ink: #211f1b;
  --muted: #7b7165;
  --line: #e5d9ca;
  --gold: #9a6a3a;
  --gold-soft: #c8a77c;
  --green: #3f6b53;
  --red: #a94438;
  --sidebar: #1d1b17;
  --sidebar-muted: #b9aa97;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.serif { font-family: "Songti SC", "STSong", "SimSun", serif; }

.app-shell { min-height: 100vh; }
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 246px; flex: 0 0 auto; background: var(--sidebar); color: #f7efe3;
  padding: 32px 20px 24px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.brand { padding: 0 10px 28px; border-bottom: 1px solid rgba(200,167,124,.22); }
.brand-name { font-size: 28px; letter-spacing: 4px; }
.brand-sub { margin-top: 6px; color: var(--sidebar-muted); font-size: 11px; letter-spacing: 3px; }
.nav { margin-top: 26px; display: flex; flex-direction: column; gap: 4px; }
.nav button {
  border: 0; background: transparent; color: var(--sidebar-muted); text-align: left;
  padding: 12px 14px; border-radius: 10px; font-size: 14px; letter-spacing: 1px;
}
.nav button:hover { background: rgba(255,255,255,.05); color: #f7efe3; }
.nav button.active { background: #f7efe3; color: var(--ink); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 16px 10px 0; color: #8f8271; font-size: 12px; line-height: 1.7; }
.sidebar-foot button { border: 0; background: transparent; color: var(--gold-soft); padding: 0; font-size: 12px; }

.main { flex: 1; min-width: 0; padding: 28px 38px 60px; }
.topbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 26px; }
.page-kicker { color: #a1907d; font-size: 11px; letter-spacing: 3px; }
.page-title { margin: 5px 0 0; font-size: 30px; font-weight: 600; letter-spacing: 1px; }
.page-sub { margin-top: 5px; color: var(--muted); font-size: 13px; }
.top-actions { display: flex; gap: 10px; align-items: center; }

.btn { border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 9px 15px; border-radius: 9px; font-size: 13px; }
.btn:hover { border-color: #cdbba5; }
.btn.primary { background: var(--ink); color: #f7efe3; border-color: var(--ink); }
.btn.primary:hover { background: #33302a; }
.btn.danger { color: var(--red); border-color: #e3b9b2; background: #fff8f6; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.metric { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 18px 18px 16px; }
.metric-label { color: var(--muted); font-size: 12px; letter-spacing: 1px; }
.metric-num { margin-top: 8px; font-size: 30px; font-weight: 600; letter-spacing: 0; }
.metric-sub { margin-top: 4px; color: #9b8f80; font-size: 11px; }

.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-title { font-size: 17px; font-weight: 600; }
.panel-sub { color: var(--muted); font-size: 12px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; color: #9b8f80; font-weight: 500; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 10px; border-bottom: 1px solid #f0e9df; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fcf8f2; }
.table-note { color: var(--muted); font-size: 12px; }
.status-pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; background: #f0e5d6; color: #8a5d31; white-space: nowrap; }
.status-pill.pending { background: #fbeceb; color: var(--red); }
.status-pill.paid { background: #edf3ee; color: var(--green); }
.status-pill.completed { background: #e8f1eb; color: var(--green); }
.status-pill.refunded, .status-pill.refund_pending, .status-pill.expired, .status-pill.void, .status-pill.cancelled, .status-pill.inactive { background: #eeeae3; color: #7b7165; }
.status-pill.active { background: #edf3ee; color: var(--green); }
.status-pill.used { background: #f4efe6; color: #6d5c47; }
.status-pill.unused { background: #eef4ef; color: var(--green); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.input, .select, .textarea {
  border: 1px solid var(--line); border-radius: 9px; background: #fff; padding: 9px 11px; font-size: 13px; color: var(--ink);
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid #d9c5aa; outline-offset: 0; }
.input.search { min-width: 240px; }
.textarea { min-height: 96px; resize: vertical; width: 100%; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.field .input, .field .select { width: 100%; }
.help { margin-top: 5px; color: #a99b88; font-size: 11px; line-height: 1.5; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #efe3d3, transparent 50%), var(--bg); }
.login-card { width: 100%; max-width: 420px; background: var(--paper); border: 1px solid var(--line); border-radius: 22px; padding: 34px 30px; box-shadow: 0 30px 80px rgba(60, 45, 28, .12); }
.login-brand { font-size: 32px; letter-spacing: 4px; }
.login-sub { margin-top: 6px; color: var(--muted); font-size: 12px; letter-spacing: 2px; }
.login-title { margin: 30px 0 4px; font-size: 24px; }
.login-hint { color: var(--muted); font-size: 12px; margin-bottom: 20px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form .input { width: 100%; height: 44px; }
.login-form .btn { height: 44px; }
.login-error { color: var(--red); font-size: 12px; min-height: 18px; }
.login-demo { margin-top: 18px; color: #a99b88; font-size: 11px; line-height: 1.7; }

.modal-mask { position: fixed; inset: 0; background: rgba(20, 18, 15, .46); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100; }
.modal { width: 100%; max-width: 760px; max-height: 90vh; overflow: auto; background: var(--paper); border-radius: 18px; box-shadow: 0 30px 90px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--paper); z-index: 2; }
.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { border: 0; background: transparent; font-size: 22px; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--paper); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; font-size: 13px; }
.detail-row { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px dashed #efe6db; }
.detail-label { width: 92px; flex: 0 0 auto; color: var(--muted); }
.detail-value { word-break: break-all; }
.code { font-family: Consolas, monospace; letter-spacing: .5px; font-size: 12px; }

.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.loading { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

.toast-root { position: fixed; right: 20px; bottom: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 14px; border-radius: 10px; background: var(--ink); color: #f7efe3; font-size: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.18); }
.toast.error { background: var(--red); }

@media (max-width: 900px) {
  .layout { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 18px; }
  .nav { flex-direction: row; overflow-x: auto; }
  .nav button { white-space: nowrap; }
  .sidebar-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 4px 0; }
  .main { padding: 20px 16px 40px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .input, .select, .textarea { font-size: 16px; }
}

@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .metric-num { font-size: 24px; overflow-wrap: anywhere; }
  .toast { max-width: calc(100vw - 32px); }
}

/* FIX(AUDIT-MF-012): 列表分页控件 */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding-top: 14px; border-top: 1px solid #f0e9df; margin-top: 12px; }
.pager-info { color: var(--muted); font-size: 12px; }
.list-note { padding-top: 12px; color: #a99b88; font-size: 12px; }

/* FIX(AUDIT-MF-018): 审计日志详情（已转义后的原始 JSON） */
.audit-detail { margin: 0; max-width: 360px; white-space: pre-wrap; word-break: break-all; font-family: Consolas, monospace; font-size: 11px; color: #6f6458; line-height: 1.5; }

/* FIX(AUDIT-MF-005): 图集只读展示 */
.gallery-box { border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; background: #fcf8f2; }
.gallery-item { padding: 4px 0; font-size: 12px; word-break: break-all; }
.gallery-item .code { color: #6f6458; }
