/* =========================================================
   嵐瑞LeRee · 独立自适应管理后台样式表 (PC 桌面 + 手机平板自适应)
   ========================================================= */
@font-face { font-family:'LRSerif'; font-weight:300; font-display:swap; src:url('/assets/serif-300.woff2') format('woff2'); }
@font-face { font-family:'LRSerif'; font-weight:400; font-display:swap; src:url('/assets/serif-400.woff2') format('woff2'); }
@font-face { font-family:'LRSerif'; font-weight:500; font-display:swap; src:url('/assets/serif-500.woff2') format('woff2'); }
@font-face { font-family:'LRSerifExtra'; font-weight:300 500; font-display:swap; src:url('/assets/serif-extra-400.woff2') format('woff2'); }

:root {
  --paper:   #F5F1EA;
  --paper-2: #EFE9DF;
  --card:    #F8F5EF;
  --ink:     #2B2822;
  --ink-2:   #57534A;
  --ink-3:   #8B8478;
  --ink-4:   #ADA697;
  --gold:    #B08D57;
  --gold-d:  #8E6E3D;
  --gold-soft: rgba(176,141,87,.12);
  --green:   #3D6B52;
  --red:     #9E4739;
  --line:    #DFD8C9;
  --line-2:  #EAE4D8;
  --serif:   'LRSerif', 'LRSerifExtra', 'Songti SC', 'Source Han Serif SC', 'Noto Serif SC', SimSun, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }

/* ---------------- 登录门禁 ---------------- */
.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 20%, #FAF7F1 0%, #EAE2D4 100%);
}
.login-box {
  width: 100%;
  max-width: 410px;
  background: var(--card);
  border: 1px solid var(--line-2);
  padding: 38px 34px 32px;
  box-shadow: 0 24px 60px rgba(43,40,34,.08);
  text-align: center;
}
.login-logo { height: 74px; margin: 0 auto 18px; display: block; object-fit: contain; }
.login-box h1 { font-size: 19px; font-weight: 400; letter-spacing: .16em; margin-bottom: 8px; }
.login-box p { font-size: 12px; color: var(--ink-3); letter-spacing: .06em; margin-bottom: 26px; }
.login-box form { text-align: left; }
.login-tip {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed var(--line-2);
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.8;
}
.login-tip code { background: var(--paper-2); padding: 2px 6px; color: var(--gold-d); }

/* ---------------- 主框架布局 ---------------- */
.adm-app {
  display: flex;
  min-height: 100vh;
}
.adm-side {
  width: 248px;
  flex-shrink: 0;
  background: #23201B;
  color: #EAE4D8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}
.adm-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.adm-logo img {
  height: 44px;
  width: 44px;
  object-fit: contain;
  background: #F5F1EA;
  padding: 4px;
  border-radius: 2px;
}
.adm-logo b { display: block; font-size: 13.5px; font-weight: 500; letter-spacing: .14em; color: #F5F1EA; }
.adm-logo span { font-size: 10.5px; color: rgba(234,228,216,.55); letter-spacing: .08em; }

.adm-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  margin-bottom: 4px;
  color: rgba(234,228,216,.72);
  font-size: 13px;
  letter-spacing: .08em;
  text-align: left;
  border-radius: 2px;
  transition: all .18s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #FFF; }
.nav-item.on {
  background: linear-gradient(90deg, rgba(176,141,87,.26), rgba(176,141,87,.08));
  color: #E8C994;
  border-left: 2px solid var(--gold);
}
.nav-badge {
  font-size: 10.5px;
  padding: 1px 7px;
  background: rgba(176,141,87,.28);
  color: #F4DEC0;
  border-radius: 10px;
}

.adm-side-ft {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
}
.int-badges { display: flex; flex-direction: column; gap: 5px; color: rgba(234,228,216,.65); }
.int-row { display: flex; justify-content: space-between; font-size: 11px; }
.int-row em { font-style: normal; color: #C9A972; }

.adm-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adm-header {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.adm-hd-l { display: flex; align-items: center; gap: 14px; }
.adm-hd-l h2 { font-size: 18px; font-weight: 400; letter-spacing: .12em; }
.adm-hd-l span { font-size: 11.5px; color: var(--ink-3); letter-spacing: .04em; }
.adm-hd-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.adm-burger { display: none; font-size: 20px; padding: 4px 8px; border: 1px solid var(--line-2); }

.adm-content {
  width: 100%;
  min-width: 0;
  padding: 24px 28px 48px;
  container: admin-workspace / inline-size;
}

/* ---------------- 统计卡片与面板 ---------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 18px 20px;
}
.kpi-card small { display: block; font-size: 11.5px; color: var(--ink-3); letter-spacing: .08em; }
.kpi-card b { display: block; font-size: 24px; font-weight: 400; margin-top: 8px; color: var(--ink); }
.kpi-card span { display: block; font-size: 11px; color: var(--gold-d); margin-top: 4px; }

.panel {
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--line);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.panel-hd h3 { font-size: 15px; font-weight: 500; letter-spacing: .1em; }
.panel-hd p { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.panel-hd > * { min-width: 0; max-width: 100%; }
.panel-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.panel-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}
.panel-pair > .panel { margin: 0; container: paired-panel / inline-size; }

/* ---------------- 表单与按钮 ---------------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.rule-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 16px; }
.rule-fields .f-group { display: flex; flex-direction: column; margin: 0; }
.rule-fields .f-inp { margin-top: auto; }
.f-group { min-width: 0; margin-bottom: 15px; }
.f-lbl { display: block; font-size: 12px; color: var(--ink-2); letter-spacing: .06em; margin-bottom: 6px; }
.f-inp, .f-sel, .f-area {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 9px 12px;
  background: #FFF;
  border: 1px solid var(--line-2);
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
}
.f-inp:focus, .f-sel:focus, .f-area:focus { border-color: var(--gold); }
.f-area { min-height: 76px; resize: vertical; line-height: 1.6; }
.f-hint { font-size: 11.5px; color: var(--ink-3); margin-top: 5px; line-height: 1.6; }

.assistant-form, .assistant-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.assistant-form .f-group { margin: 0; }
.assistant-form > button { justify-self: start; }
.assistant-qr-editor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}
.assistant-qr-editor img {
  width: 128px;
  height: 128px;
  padding: 8px;
  object-fit: contain;
  background: #FFF;
  border: 1px solid var(--line);
}
.assistant-qr-editor > div { flex: 1 1 220px; min-width: 0; }

.mode-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.mode-tab {
  padding: 12px 10px;
  border: 1px solid var(--line-2);
  background: #FAF7F1;
  text-align: center;
  transition: all .15s;
}
.mode-tab b { display: block; font-size: 13px; font-weight: 500; }
.mode-tab span { display: block; font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.mode-tab.on {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: var(--gold-d);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 22px;
  background: var(--ink);
  color: #F5F1EA;
  font-size: 13px;
  letter-spacing: .12em;
}
.btn-primary:hover { background: #3E3A32; }
.btn-primary.gold { background: var(--gold-d); }
.btn-primary.wide, .btn-ghost.wide { width: 100%; }
.btn-ghost {
  height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(255,255,255,.22);
  color: rgba(234,228,216,.85);
  font-size: 12px;
}
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 31px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  background: #FFF;
  font-size: 12px;
  letter-spacing: .04em;
  white-space: nowrap;
}
.btn-sm:hover { border-color: var(--gold); color: var(--gold-d); }
.btn-sm.gold { background: var(--gold-d); border-color: var(--gold-d); color: #FFF; }
.btn-sm.danger { color: var(--red); border-color: rgba(158,71,57,.3); }

/* ---------------- 数据表格 ---------------- */
.tbl-wrap { width: 100%; max-width: 100%; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl:has(thead th:nth-child(7)) { min-width: 960px; }
.levels-table { table-layout: fixed; min-width: 800px; }
.levels-table th:nth-child(1) { width: 8%; }
.levels-table th:nth-child(2) { width: 10%; }
.levels-table th:nth-child(3) { width: 13%; }
.levels-table th:nth-child(4) { width: 16%; }
.levels-table th:nth-child(5) { width: 18%; }
.table-empty { padding: 22px 10px; color: var(--ink-3); text-align: center; font-size: 13px; }
.tbl th {
  text-align: left;
  padding: 11px 12px;
  background: #F7F3EB;
  color: var(--ink-2);
  font-weight: 500;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.tbl td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  line-height: 1.55;
}
.tbl tr:hover td { background: rgba(176,141,87,.04); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  border: 1px solid var(--line-2);
  background: #FAF7F1;
}
.badge.gold { border-color: rgba(176,141,87,.45); background: var(--gold-soft); color: var(--gold-d); }
.badge.ok { border-color: rgba(61,107,82,.35); background: rgba(61,107,82,.09); color: var(--green); }
.badge.warn { border-color: rgba(158,71,57,.35); background: rgba(158,71,57,.08); color: var(--red); }

.thumb { width: 46px; height: 46px; object-fit: cover; border: 1px solid var(--line); vertical-align: middle; }

/* ---------------- 弹窗与电子面单 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(25,22,18,.52);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 90;
}
.modal-mask.show { display: flex; }
.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line-2);
  padding: 26px 28px;
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}
.waybill-sheet {
  border: 2px solid #1E1E1E;
  background: #FFF;
  padding: 16px;
  font-family: 'Microsoft YaHei', sans-serif;
  color: #111;
}
.wb-top { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #111; padding-bottom: 10px; }
.wb-bars {
  height: 44px;
  margin: 12px 0 6px;
  background: repeating-linear-gradient(90deg, #111 0 2px, #fff 2px 5px, #111 5px 9px, #fff 9px 12px);
}
.wb-row { border-top: 1px solid #333; padding: 8px 0; font-size: 12px; line-height: 1.6; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(16px);
  background: rgba(35,32,27,.94);
  color: #F5F1EA;
  padding: 10px 22px;
  font-size: 12.5px;
  letter-spacing: .08em;
  opacity: 0;
  pointer-events: none;
  transition: all .22s;
  z-index: 120;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.adm-overlay { display: none; }

/* ---------------- 手工录积分工作台 ---------------- */
.points-layout, .points-side { display: grid; gap: 20px; align-content: start; min-width: 0; }
.points-layout { align-items: start; }
.points-layout .panel { margin: 0; }
.points-layout h3 { font-size: 17px; }
.points-form { container: points-form / inline-size; }
.points-form .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.points-form .grid-2:last-child .f-group { margin-bottom: 0; }
.points-form select:disabled { opacity: 1; color: var(--ink-3); }

.points-review { border-top: 2px solid var(--gold); }
.review-member { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; }
.review-member span, .review-member small, .review-action span { font-size: 12px; color: var(--ink-2); }
.review-member strong { font-size: 16px; font-weight: 500; overflow-wrap: anywhere; }
.review-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0;
  padding: 18px 0;
  background: var(--paper-2);
}
.review-totals > div { padding: 0 clamp(8px, 1.15vw, 22px); }
.review-totals > div + div { border-left: 1px solid var(--line); }
.review-totals dt { font-size: 12px; color: var(--ink-2); }
.review-totals dd {
  margin-top: 6px;
  font-size: clamp(22px, 1.6vw, 30px);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.points-increase dd { color: var(--gold-d); }
.review-action { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.review-action button:disabled { cursor: default; background: var(--line); color: var(--ink-2); }
.points-empty { padding: 20px 0 24px; text-align: center; }
.points-empty strong { font-size: 15px; font-weight: 400; }
.points-empty p { margin: 6px 0 0; color: var(--ink-2); font-size: 12px; line-height: 1.7; }

.points-record + .points-record { border-top: 1px solid var(--line-2); }
.points-record summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) auto 7px;
  align-items: center;
  gap: 12px;
  padding: 12px 2px;
  font-size: 13px;
  cursor: pointer;
  overflow-wrap: anywhere;
  list-style: none;
}
.points-record summary::-webkit-details-marker { display: none; }
.points-record summary::after {
  content: "";
  width: 6px;
  height: 6px;
  border: solid var(--ink-3);
  border-width: 0 1px 1px 0;
  transform: rotate(45deg);
}
.points-record[open] summary::after { transform: rotate(225deg); }
.points-record summary:focus-visible { outline: 2px solid var(--gold-d); outline-offset: 1px; }
.points-record strong { font-weight: 500; }
.points-record small { display: block; margin-top: 3px; color: var(--ink-2); font-size: 11px; }
.record-value { text-align: right; font-variant-numeric: tabular-nums; }
.credit { color: var(--green); }
.debit { color: var(--red); }
.record-detail {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--paper);
  font-size: 12px;
}
.record-detail dt { color: var(--ink-2); }
.record-detail dd { overflow-wrap: anywhere; }

@container admin-workspace (min-width: 950px) {
  .panel-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .assistant-form { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: 28px; }
  .assistant-qr-field { padding-left: 28px; border-left: 1px solid var(--line); }
  .assistant-form > button { grid-column: 1 / -1; justify-self: end; }
}
@container paired-panel (max-width: 530px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@container admin-workspace (min-width: 1050px) {
  .points-layout { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
}
@container admin-workspace (min-width: 1400px) {
  .kpi-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 5px 14px; padding: 22px 24px; }
  .kpi-card b { grid-column: 2; grid-row: 1 / 3; margin: 0; font-size: 30px; }
  .kpi-card span { margin: 0; }
  .panel { padding: clamp(24px, 1.5vw, 38px); }
  .panel-hd h3 { font-size: 19px; }
  .panel-hd p, .f-lbl, .tbl { font-size: 13px; }
  .points-form .mode-tab { padding: 17px 12px; }
  .points-form .f-inp, .points-form .f-sel { min-height: 44px; font-size: 14px; }
  .review-totals { padding: 23px 0; margin: 20px 0; }
  .points-empty { padding: 24px 0 28px; }
}
@container points-form (max-width: 740px) {
  .mode-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container points-form (max-width: 530px) {
  .points-form .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .points-form .grid-2:last-child .f-group + .f-group { margin-top: 15px; }
}

/* ---------------- 手机与平板自适应 ---------------- */
@media (max-width: 920px) {
  .adm-side {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    transition: left .24s ease;
  }
  .adm-side.open { left: 0; }
  .adm-overlay.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 35;
  }
  .adm-burger { display: inline-block; }
  .adm-header { padding: 12px 16px; }
  .adm-content { padding: 16px 14px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mode-tabs { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .adm-header { flex-wrap: wrap; gap: 8px; }
  .adm-hd-l { width: 100%; gap: 10px; }
  .adm-hd-l span { display: none; }
  .adm-hd-r { margin-left: 48px; }
  .points-layout, .points-side, .panel-pair { gap: 14px; }
  .panel { padding: 16px; }
  .kpi-grid { gap: 10px; margin-bottom: 14px; }
  .kpi-card { padding: 12px; }
  .review-totals dt { font-size: 11px; }
  .points-record summary { gap: 8px; }
}
