/*! MP Tool · 基础层：设计变量 / 重置 / 通用组件 */

:root {
  --brand: #5b7a1e;
  --brand-600: #4f6c18;
  --brand-700: #3f5711;
  --brand-100: #e9f1d6;
  --brand-50: #f3f8e7;

  --bg: #fbfbf8;
  --surface: #ffffff;
  --sidebar: #f6f8ef;
  --border: #eaeaE3;
  --border-strong: #dcdcd3;

  --text: #1e2219;
  --text-2: #55594e;
  --muted: #8d9187;

  --ok-bg: #e8f2d8;
  --ok-fg: #4c6a15;
  --warn-bg: #fdf3e0;
  --warn-fg: #94651a;
  --err-bg: #fdecea;
  --err-fg: #b8442f;
  --info-bg: #e9f0fb;
  --info-fg: #3a67ad;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 26, 10, .045);
  --shadow: 0 2px 10px rgba(20, 26, 10, .06);
  --shadow-lg: 0 22px 56px rgba(18, 24, 8, .22);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", "Courier New", monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.is-locked { overflow: hidden; }

h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
b, strong { font-weight: 700; }

code { font-family: var(--mono); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d9dbd2; border: 3px solid transparent; background-clip: content-box; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #c3c7b8; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.icon { display: block; flex-shrink: 0; }

/* ---------------- 品牌标 ---------------- */
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(150deg, #6c8f28, #4a6614);
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(60, 84, 16, .22);
}
.brand-mark--square { border-radius: 10px; }
.brand-mark--circle { border-radius: 50%; }
.brand-mark svg { margin-left: 2px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, opacity .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn > span { line-height: 1; }

.btn--primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(60, 84, 16, .24); }
.btn--primary:hover:not(:disabled) { background: var(--brand-600); }
.btn--primary:active:not(:disabled) { background: var(--brand-700); }

.btn--soft { background: var(--brand-100); color: var(--brand-700); }
.btn--soft:hover:not(:disabled) { background: #dfebc8; }

.btn--ghost { background: #fff; border-color: var(--border-strong); color: var(--text-2); }
.btn--ghost:hover:not(:disabled) { border-color: #c7cbbc; color: var(--text); background: #fbfcf8; }

.btn--danger { background: #b8442f; color: #fff; }
.btn--danger:hover:not(:disabled) { background: #a33a26; }

.btn--sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn--block { width: 100%; }
.btn--nowrap { flex-shrink: 0; }
.btn--wxv { font-family: var(--mono); letter-spacing: .2px; font-size: 12.5px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: #f1f2ec; color: var(--text-2); }
.icon-btn--danger:hover { background: #fbeae6; color: #bf4527; }
.icon-btn--back { border-color: var(--border-strong); background: #fff; color: var(--text-2); width: 36px; height: 36px; }
.icon-btn--back:hover { background: #fbfcf8; color: var(--text); }
.icon-btn.is-spinning svg { animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.field label .icon { color: var(--muted); }

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #a9ada2; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 122, 30, .13); }

/* 下拉 */
.select { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; }
.select select {
  appearance: none;
  height: 38px;
  padding: 0 34px 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  font-size: 13.5px;
  color: var(--text-2);
  cursor: pointer;
}
.select select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 122, 30, .13); }
.select > .icon { position: absolute; right: 11px; color: var(--muted); pointer-events: none; }

/* 搜索框 */
.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 180px;
  max-width: 420px;
  height: 38px;
  padding: 0 12px;
  gap: 9px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.search > .icon { color: var(--muted); }
.search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 13.5px;
  outline: none;
}
.search input::placeholder { color: #a9ada2; }
.search input::-webkit-search-cancel-button { display: none; }
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(91, 122, 30, .13); }

/* 复选框 */
.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.checkbox input { position: absolute; width: 0; height: 0; opacity: 0; }
.checkbox__box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 1.5px solid #c9cdbf;
  border-radius: 5px;
  background: #fff;
  color: #fff;
  flex-shrink: 0;
  transition: background .14s, border-color .14s;
}
.checkbox__box .icon { opacity: 0; transition: opacity .12s; }
.checkbox input:checked + .checkbox__box { background: var(--brand); border-color: var(--brand); }
.checkbox input:checked + .checkbox__box .icon { opacity: 1; }
.checkbox:hover .checkbox__box { border-color: var(--brand); }
.checkbox__text { font-size: 13px; color: var(--text-2); }
.checkbox__text b { color: var(--text); }
.checkbox--row { padding: 2px; }

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}
.badge--ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge--warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge--err { background: var(--err-bg); color: var(--err-fg); }
.badge--info { background: var(--info-bg); color: var(--info-fg); }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 18px;
}
.card--actions { display: flex; align-items: center; gap: 10px; padding: 16px 22px; }

/* ---------------- 头像 / 缩略图 ---------------- */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: linear-gradient(140deg, #7c9c38, #4a6614);
  color: #fff;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}
.avatar--lg { width: 46px; height: 46px; border-radius: 13px; font-size: 20px; }

.thumb {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(20, 30, 5, .06);
}
.thumb__glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .86);
  color: #4a6614;
}
.thumb__glyph--plain { width: auto; height: auto; background: transparent; color: rgba(255, 255, 255, .92); }

/* 真实封面：盖在渐变占位之上；加载失败则隐藏，自动露出占位 */
.thumb__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: #eef1e6;
}
.thumb__img.is-broken { display: none; }

/* ---------------- 空状态 ---------------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 54px 20px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}
.empty > .icon { color: #c2c8b4; }

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 82vw;
  padding: 10px 18px;
  border-radius: 999px;
  background: #4a6614;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 28px rgba(45, 62, 12, .3);
  opacity: 0;
  transform: translateY(-12px) scale(.96);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.is-in { opacity: 1; transform: none; }
.toast--err { background: #9c3a24; box-shadow: 0 12px 28px rgba(90, 30, 16, .3); }
.toast__icon { display: flex; opacity: .9; }
.toast__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 30, 18, .42);
  backdrop-filter: blur(1.5px);
  opacity: 0;
  transition: opacity .18s ease;
}
.modal-overlay.is-in { opacity: 1; }
.modal {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  max-height: 88vh;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(.98);
  transition: transform .18s ease;
}
.modal-overlay.is-in .modal { transform: none; }
.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 0;
}
.modal__title { font-size: 17px; font-weight: 700; letter-spacing: -.2px; }
.modal__subtitle {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-all;
}
.modal__body { padding: 18px 22px; overflow: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }
.modal__foot .btn--block { flex: 1; }
.modal__text { font-size: 13.5px; color: var(--text-2); line-height: 1.7; }

/* ---------------- 分段控件 ---------------- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 2px;
  padding: 3px;
  background: #f2f3ec;
  border-radius: 11px;
}
.segmented__item {
  height: 34px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.segmented__item:hover { color: var(--text); }
.segmented__item.is-active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 3px rgba(20, 26, 10, .12);
}

/* ---------------- 选项卡 ---------------- */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  flex-shrink: 0;
}
.tabs__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tabs__item:hover { background: #f6f7f2; }
.tabs__item.is-active { background: var(--brand-100); color: var(--brand-700); }

/* ---------------- 工具条 ---------------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* ---------------- 分页 ---------------- */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pager__info { font-size: 13px; color: var(--muted); }
.pager__nav { display: flex; align-items: center; gap: 4px; }
.pager__num, .pager__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 33px;
  height: 33px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.pager__num:hover, .pager__btn:hover:not(:disabled) { background: #f1f2ec; }
.pager__num.is-active { background: var(--brand); color: #fff; }
.pager__btn:disabled { opacity: .38; cursor: not-allowed; }
.pager__gap { padding: 0 2px; color: var(--muted); }
