/* ============================================================
   小任卡密兑换 · 设计令牌 + 基础组件
   register=product · 暖中性墨色 + 单一琥珀强调 · 实色面 / 弱边框
   ============================================================ */

:root {
  /* 暖中性色阶：整体偏纸感，绝不使用纯白纯黑 */
  --bg:          #F6F3EE;
  --surface:     #FFFDFA;
  --surface-2:   #F1ECE4;
  --surface-3:   #E7E0D5;
  --ink:         #1B1917;
  --ink-2:       #46403A;
  --ink-3:       #6B635B;
  --line:        rgba(27, 25, 23, 0.09);
  --line-strong: rgba(27, 25, 23, 0.16);

  /* 单一强调色：赭石铜 */
  --accent:      #A85B18;
  --accent-ink:  #7E4310;
  --accent-soft: #F5E7D5;
  --accent-line: rgba(168, 91, 24, 0.28);

  /* 语义色（状态专用，不参与装饰） */
  --ok:          #2E6B4E;
  --ok-soft:     #E3EFE7;
  --warn:        #8A6114;
  --warn-soft:   #F6EBD5;
  --bad:         #A3342A;
  --bad-soft:    #F7E4E1;
  --idle:        #6B635B;
  --idle-soft:   #EDE8E0;

  --radius-1: 6px;
  --radius-2: 8px;
  --radius-3: 12px;

  --shadow-pop: 0 1px 2px rgba(27, 25, 23, 0.05), 0 12px 32px -16px rgba(27, 25, 23, 0.28);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  --nav-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  overflow-x: clip;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.012em; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* ---- 排版档位 ---- */
.t-display { font-size: 27px; line-height: 1.18; font-weight: 700; letter-spacing: -0.028em; }
.t-h1      { font-size: 20px; line-height: 1.28; font-weight: 680; letter-spacing: -0.02em; }
.t-h2      { font-size: 16px; line-height: 1.35; font-weight: 650; }
.t-body    { font-size: 14px; }
.t-sm      { font-size: 13px; }
.t-xs      { font-size: 12px; }
.t-mono    { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.t-num     { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }

.muted { color: var(--ink-3); }
.dim   { color: var(--ink-2); }

/* ---- 卡片 ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-3);
}
.card-pad { padding: 16px 18px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  border-radius: var(--radius-2);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 主操作：墨黑实底（工作台的默认主按钮） */
.btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #FBF8F3;
}
.btn-primary:hover:not(:disabled) { background: #2C2926; border-color: #2C2926; }
.btn-primary:active:not(:disabled) { background: #3A3631; }

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFF8F1;
}
.btn-accent:hover:not(:disabled) { background: var(--accent-ink); border-color: var(--accent-ink); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

.btn-danger { color: var(--bad); border-color: rgba(163, 52, 42, 0.28); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14px; }
.btn-block { width: 100%; }

/* ---- 表单 ---- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12px; font-weight: 600; color: var(--ink-2); letter-spacing: 0.01em; }
.field .hint { font-size: 12px; color: var(--ink-3); }

.input, .select, .textarea {
  height: 34px;
  padding: 0 11px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 72px; }
.input::placeholder, .textarea::placeholder { color: #A79E95; }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(27, 25, 23, 0.24); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.select { appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

/* ---- 徽标 / 状态 ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  background: var(--idle-soft);
  color: var(--idle);
}
.badge::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-ok    { background: var(--ok-soft);   color: var(--ok); }
.badge-warn  { background: var(--warn-soft); color: var(--warn); }
.badge-bad   { background: var(--bad-soft);  color: var(--bad); }
.badge-accent{ background: var(--accent-soft); color: var(--accent-ink); }
.badge-plain { background: var(--surface-2); color: var(--ink-2); }
.badge-plain::before { display: none; }

/* ---- 表格 ---- */
.table-wrap { overflow-x: auto; }
table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.tbl th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  color: var(--ink-3);
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.tbl td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: rgba(168, 91, 24, 0.035); }
table.tbl td.num, table.tbl th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.tbl .row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---- 空态 ---- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 20px;
  color: var(--ink-3);
  text-align: center;
}
.empty strong { color: var(--ink-2); font-size: 14px; font-weight: 600; }

/* ---- 抽屉 ---- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(27, 25, 23, 0.32);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--surface);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow-pop);
  z-index: 61;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1);
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.drawer-body { flex: 1; overflow-y: auto; padding: 18px; }
.drawer-foot {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2);
}

/* ---- Toast ---- */
.toasts {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: #FBF8F3;
  padding: 9px 15px;
  border-radius: var(--radius-2);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: toastIn 200ms cubic-bezier(0.32, 0.72, 0, 1);
  max-width: min(92vw, 520px);
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- 工具 ---- */
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
