/* 工作台统一设计系统：浅色 / 深色跟随系统 */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --line: #e2e5e9;
  --line-2: #eef0f3;
  --text: #1b1f24;
  --text-2: #59626e;
  --text-3: #8a93a0;
  --brand: #2f6fed;
  --brand-soft: #e9f0fe;
  --ok: #17914f;
  --ok-soft: #e5f6ec;
  --warn: #b4761a;
  --warn-soft: #fdf3e1;
  --bad: #cf3f3f;
  --bad-soft: #fdeaea;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #13161b;
    --panel: #1b1f26;
    --panel-2: #21262e;
    --line: #2d333c;
    --line-2: #262b33;
    --text: #e7eaee;
    --text-2: #a4adb9;
    --text-3: #79828f;
    --brand: #5d8dff;
    --brand-soft: #1c2942;
    --ok: #3ddc84;
    --ok-soft: #143121;
    --warn: #f0b429;
    --warn-soft: #382c12;
    --bad: #ff6b6b;
    --bad-soft: #3a1d1d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 600; font-size: 15px; letter-spacing: .5px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
}
.nav a:hover { background: var(--panel-2); text-decoration: none; }
.nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.topbar .user { display: flex; align-items: center; gap: 10px; color: var(--text-2); }

.wrap { padding: 18px 20px 40px; max-width: 1600px; margin: 0 auto; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.page-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 14px; }
.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { padding: 16px; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th, .table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
  vertical-align: middle;
}
.table th {
  background: var(--panel-2);
  color: var(--text-2);
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody tr:hover { background: var(--panel-2); }
.table td.wrap-cell { white-space: normal; max-width: 240px; word-break: break-word; }
.table td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: none; }
.row-link { cursor: pointer; }

/* ---------------------------------------------------------------- 表单 */
.field, select, textarea, input[type="text"], input[type="password"], input[type="search"] {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  min-width: 0;
}
.field:focus, select:focus, textarea:focus, input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { resize: vertical; line-height: 1.7; }
label { display: block; color: var(--text-2); font-size: 12px; margin-bottom: 5px; }

.btn {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 13px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; color: var(--text-2); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------------------------------------------------------- 标签 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  line-height: 1.5;
  background: var(--panel-2);
  color: var(--text-2);
  border: 1px solid var(--line);
}
.tag.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.tag.info { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* ---------------------------------------------------------------- 秘密值 */
.secret { display: inline-flex; align-items: center; gap: 6px; }
.secret .val { font-family: var(--mono); font-size: 12px; color: var(--text-2); }
.secret .val.plain { color: var(--text); }
.eye, .copy {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-3);
  border-radius: 5px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 11px;
}
.eye:hover, .copy:hover { color: var(--brand); border-color: var(--brand); }
.eye { position: relative; }
.eye::before {
  content: "";
  width: 12px; height: 7px;
  border: 1.5px solid currentColor;
  border-radius: 50% / 70%;
  display: block;
}
.eye::after {
  content: "";
  position: absolute;
  width: 4px; height: 4px;
  background: currentColor;
  border-radius: 50%;
}
.eye.off::after { display: none; }
.copy { font-size: 10px; letter-spacing: -.5px; }

/* ---------------------------------------------------------------- 状态 */
.empty { padding: 40px 16px; text-align: center; color: var(--text-3); }
.muted { color: var(--text-3); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--panel);
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all .18s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- 登录 */
.center { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 26px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 { margin: 0 0 4px; font-size: 18px; font-weight: 600; }
.login-card .sub { margin: 0 0 20px; color: var(--text-3); font-size: 12px; }
.login-card .field { width: 100%; margin-bottom: 12px; }
.login-card .btn { width: 100%; margin-top: 4px; }
.login-card .hint { margin: 14px 0 0; font-size: 12px; color: var(--text-3); }
.login-card code { font-family: var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

/* ---------------------------------------------------------------- 视图切换 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 9px 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 500; }
.view { display: none; }
.view.on { display: block; }

/* ---------------------------------------------------------------- 弹层 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}
.modal-mask.on { display: flex; }
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  width: 100%;
  max-width: 900px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; align-items: center; }
.kv dt { color: var(--text-2); font-size: 12px; }
.kv dd { margin: 0; min-width: 0; word-break: break-all; }

.section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 20px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.section-title:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- 统计卡 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .k { color: var(--text-3); font-size: 12px; }
.stat .v { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- 下单页 */
.order-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
@media (max-width: 1100px) {
  .order-layout { grid-template-columns: 1fr; }
}
.group-list { display: flex; flex-direction: column; gap: 8px; }
.group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  cursor: pointer;
}
.group.on { border-color: var(--brand); background: var(--brand-soft); }
.group .handle { color: var(--text-3); cursor: grab; user-select: none; font-size: 13px; }
.group .thumb {
  width: 38px; height: 38px;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  object-fit: cover;
  flex-shrink: 0;
}
.group .meta { min-width: 0; flex: 1; }
.group .meta b { font-size: 12.5px; font-weight: 500; display: block; }
.group .meta span { font-size: 11.5px; color: var(--text-3); }
.group .del { color: var(--text-3); border: none; background: none; cursor: pointer; padding: 2px 4px; }
.group .del:hover { color: var(--bad); }
.group-add {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
}
.group-add:hover { border-color: var(--brand); color: var(--brand); }

.drop {
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 22px 12px;
  text-align: center;
  color: var(--text-3);
  cursor: pointer;
  background: var(--panel-2);
}
.drop.over, .drop:hover { border-color: var(--brand); color: var(--brand); }
.drop-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.drop-item { position: relative; width: 62px; height: 62px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.drop-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.drop-item button {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px;
  border: none; border-radius: 50%;
  background: rgba(0, 0, 0, .6); color: #fff;
  cursor: pointer; font-size: 11px; line-height: 1; padding: 0;
}

.region-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.region-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}
.region-btn:hover { border-color: var(--brand); }
.region-btn.on { background: var(--brand-soft); border-color: var(--brand); color: var(--brand); font-weight: 500; }

.note-preview { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; }
.note-preview .cover { width: 100%; aspect-ratio: 4 / 3; border-radius: 6px; background: var(--line-2); object-fit: cover; display: block; margin-bottom: 10px; }
.note-preview .np-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.note-preview .np-body { white-space: pre-wrap; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.note-preview .np-topics { margin-top: 8px; color: var(--brand); font-size: 13px; }
.note-preview .np-empty { color: var(--text-3); font-size: 12px; padding: 30px 0; text-align: center; }

.hint-line { font-size: 12px; color: var(--warn); min-height: 18px; }
.hint-line.ok { color: var(--ok); }
