:root {
  --paper: #faf6ec;
  --paper-2: #f3ebdc;
  --surface: #fffdf7;
  --ink: #4a382e;
  --ink-soft: #6e5a4b;
  --ink-faint: #96806d;
  --line: #4a382e;
  --hairline: #e6dcc9;
  --mint: #b2e8dd;
  --red: #e72d48;
  --pink: #f1dddf;
  --yellow: #ffe76e;
  --olive: #88ae18;
  --shadow: 4px 4px 0 0 var(--line);
  --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100vh;
  font-family: "Noto Sans SC", "Source Han Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(var(--hairline) 1.2px, transparent 1.2px);
  background-size: 22px 22px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: var(--yellow); color: var(--ink); }

.wrap { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: var(--paper);
  border-bottom: 2px solid var(--line);
}
.site-header .wrap {
  height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--mint); border: 2px solid var(--line); border-radius: 10px;
  box-shadow: 3px 3px 0 0 var(--line); font-weight: 900; font-size: 20px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 900; letter-spacing: -0.02em; font-size: 17px; }
.brand-sub { font-size: 10px; font-weight: 700; letter-spacing: 0.18em; color: var(--ink-faint); }
.nav-links { display: flex; align-items: center; gap: 8px; }
.nav-link {
  padding: 8px 14px; border: 2px solid transparent; border-radius: 999px;
  font-size: 14px; font-weight: 600; transition: 0.15s ease;
}
.nav-link:hover { border-color: var(--line); background: var(--surface); }
.nav-link.active { background: var(--ink); color: var(--paper); border-color: var(--line); }

/* ---------- 通用元件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--surface); font-weight: 700; font-size: 14px;
  box-shadow: 3px 3px 0 0 var(--line);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 0 var(--line); }
.btn:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 0 var(--line); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: 3px 3px 0 0 var(--line); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-mint { background: var(--mint); }
.btn-yellow { background: var(--yellow); }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; }
.btn-ghost:hover { box-shadow: none; border-color: var(--line); background: var(--paper-2); transform: none; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; box-shadow: 2px 2px 0 0 var(--line); }
.btn-sm:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 0 var(--line); }
.btn-block { width: 100%; }
.btn-danger-text { color: var(--red); }

.card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 24px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--paper-2); font-size: 11px; font-weight: 700; line-height: 1.6;
}
.chip-mint { background: var(--mint); }
.chip-yellow { background: var(--yellow); }
.chip-red { background: var(--pink); color: var(--red); }
.chip-olive { background: #e8f0c8; color: #4f6608; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--surface); outline: none; transition: box-shadow 0.15s ease, background 0.15s ease;
}
.input:focus { box-shadow: 0 0 0 4px var(--mint); background: #fff; }
textarea.input { resize: vertical; min-height: 84px; }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }
.hint { font-size: 12px; color: var(--ink-faint); }
.error-text { color: var(--red); font-size: 13px; font-weight: 600; min-height: 18px; }

.divider { height: 2px; background: var(--line); opacity: 0.12; margin: 20px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- 登录 / 注册 ---------- */
.auth-shell {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr 0.95fr;
}
.auth-hero {
  position: relative; overflow: hidden;
  padding: 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--mint); border-right: 2px solid var(--line);
}
.auth-hero::before {
  content: ""; position: absolute; inset: auto -120px -160px auto;
  width: 420px; height: 420px; border-radius: 50%;
  background: var(--yellow); border: 2px solid var(--line);
}
.auth-hero::after {
  content: ""; position: absolute; top: -90px; right: 60px;
  width: 190px; height: 190px; border-radius: 50%;
  background: var(--pink); border: 2px solid var(--line);
}
.hero-brand { position: relative; z-index: 2; display: flex; align-items: center; gap: 12px; }
.hero-title {
  position: relative; z-index: 2;
  font-size: clamp(42px, 5.4vw, 76px); font-weight: 900; line-height: 0.98; letter-spacing: -0.045em;
  margin: 40px 0 18px;
}
.hero-title em { font-style: normal; background: var(--ink); color: var(--mint); padding: 0 10px; border-radius: 8px; }
.hero-desc { position: relative; z-index: 2; max-width: 460px; font-size: 16px; font-weight: 600; color: #3c2d24; }
.hero-meta { position: relative; z-index: 2; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 34px; }
.hero-foot { position: relative; z-index: 2; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; color: #5a4638; }

.auth-panel {
  display: flex; align-items: center; justify-content: center; padding: 40px 28px;
  background: var(--paper);
}
.auth-box { width: min(430px, 100%); }
.auth-kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.2em; color: var(--ink-faint); margin-bottom: 10px; }
.auth-title { font-size: 34px; font-weight: 900; letter-spacing: -0.04em; line-height: 1.1; }
.auth-sub { color: var(--ink-soft); margin: 8px 0 26px; font-size: 14px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; font-size: 13px; font-weight: 600; }
.text-link { color: var(--red); font-weight: 700; }
.text-link:hover { text-decoration: underline; }
.auth-note {
  margin-top: 22px; padding: 12px 14px; border: 2px dashed var(--hairline); border-radius: 10px;
  font-size: 12px; color: var(--ink-soft);
}

/* ---------- 应用布局 ---------- */
.app-shell { display: grid; grid-template-columns: 264px 1fr; gap: 24px; padding: 28px 0 64px; }
.sidebar { align-self: start; position: sticky; top: 92px; display: flex; flex-direction: column; gap: 16px; }
.user-card { padding: 20px; }
.avatar {
  width: 54px; height: 54px; border-radius: 14px; border: 2px solid var(--line);
  display: grid; place-items: center; font-weight: 900; font-size: 22px;
  background: var(--yellow); box-shadow: 3px 3px 0 0 var(--line);
}
.user-name { font-weight: 900; font-size: 17px; margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-handle { font-size: 12px; color: var(--ink-faint); }
.user-products { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; padding: 10px; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px;
  font-size: 14px; font-weight: 700; color: var(--ink-soft); border: 2px solid transparent;
}
.side-link:hover { background: var(--paper-2); color: var(--ink); }
.side-link.active { background: var(--ink); color: var(--paper); }
.side-link .ico { width: 18px; height: 18px; flex: none; }
.side-sep { height: 1px; background: var(--hairline); margin: 8px 6px; }

.main { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 30px; font-weight: 900; letter-spacing: -0.035em; line-height: 1.15; }
.page-desc { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat {
  padding: 18px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface);
  box-shadow: 3px 3px 0 0 var(--line); min-height: 108px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.stat:nth-child(1) { background: var(--mint); }
.stat:nth-child(2) { background: var(--yellow); }
.stat:nth-child(3) { background: var(--pink); }
.stat:nth-child(4) { background: var(--paper-2); }
.stat-label { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: #5a4638; }
.stat-value { font-size: 30px; font-weight: 900; letter-spacing: -0.04em; line-height: 1; }
.stat-sub { font-size: 12px; color: #6a5445; }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title h3 { font-size: 16px; font-weight: 900; letter-spacing: -0.02em; }

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1.5px dashed var(--hairline);
}
.list-row:last-child { border-bottom: none; padding-bottom: 0; }
.list-row:first-child { padding-top: 0; }
.row-main { min-width: 0; }
.row-title { font-weight: 700; font-size: 14px; }
.row-sub { font-size: 12px; color: var(--ink-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; padding: 9px 10px; font-size: 11px; font-weight: 800;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr.clickable:hover td { background: var(--paper-2); cursor: pointer; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .input { flex: 1; min-width: 180px; }

.empty {
  padding: 34px 18px; text-align: center; color: var(--ink-faint); font-size: 13px;
  border: 2px dashed var(--hairline); border-radius: 10px;
}

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 18px;
  background: rgba(74, 56, 46, 0.45);
}
.modal {
  width: min(560px, 100%); max-height: 86vh; overflow: auto;
  background: var(--surface); border: 2px solid var(--line); border-radius: 16px;
  box-shadow: 8px 8px 0 0 var(--line); padding: 24px;
}
.modal-lg { width: min(760px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-title { font-size: 20px; font-weight: 900; letter-spacing: -0.03em; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  border: 2px solid var(--line); border-radius: 8px; background: var(--surface);
}
.icon-btn:hover { background: var(--paper-2); }

/* ---------- 提示 ---------- */
.toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 16px; border: 2px solid var(--line); border-radius: 10px; background: var(--surface);
  box-shadow: 3px 3px 0 0 var(--line); font-size: 13px; font-weight: 700;
  animation: toast-in 0.2s ease;
}
.toast-success { background: var(--mint); }
.toast-error { background: var(--pink); color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.skeleton { height: 14px; border-radius: 6px; background: var(--paper-2); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.role-pill { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.role-pill span { padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); font-size: 11px; font-weight: 700; background: var(--mint); }
.role-pill span.admin { background: var(--yellow); }
.role-pill span.supreme { background: var(--red); color: #fff; }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
  .auth-panel { min-height: 100vh; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .side-link { white-space: nowrap; }
  .side-sep { display: none; }
  .stat-grid, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .site-header .wrap { height: 60px; }
  .brand-sub { display: none; }
  .nav-links .nav-link { padding: 7px 10px; font-size: 13px; }
  .stat-grid, .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .auth-panel { padding: 26px 18px; }
  .auth-title { font-size: 28px; }
  .card-pad { padding: 18px; }
  .page-title { font-size: 24px; }
  .row-sub { max-width: 220px; }
  .modal { padding: 18px; }
}
