:root {
  --bg: #fdfcf9;
  --card: #ffffff;
  --line: #ece8df;
  --line-soft: #f3efe7;
  --ink: #23241f;
  --ink-2: #6b6a62;
  --ink-3: #9b998f;
  --brand: #0f6e56;
  --brand-2: #1d9e75;
  --brand-soft: #e8f3ee;
  --danger: #b4443a;
  --danger-soft: #fbeeec;
  --amber: #b7791f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--ink); }

.hidden { display: none !important; visibility: hidden !important; }

/* ---------- 登录：卡片严格按截图比例 1:1 居中 ---------- */
.login {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(600px 300px at 20% 30%, rgba(29, 158, 117, 0.12), transparent 70%),
    radial-gradient(500px 260px at 80% 20%, rgba(183, 121, 31, 0.08), transparent 70%);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 400px;
  height: 500px;
  box-sizing: border-box;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 36px 32px;
  box-shadow: 0 20px 48px -28px rgba(35, 36, 31, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand-row { display: flex; align-items: center; gap: 9px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 4px;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
}
.brand-name { font-size: 13px; letter-spacing: 0.4px; color: var(--brand); font-weight: 600; }

.login-card h1 { margin: 22px 0 6px; font-size: 26px; letter-spacing: 0.5px; }
.login-sub { margin: 0 0 24px; color: var(--ink-2); font-size: 13px; line-height: 1.6; }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 7px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fdfdfb;
  border-radius: 11px;
  padding: 11px 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.13);
  background: #fff;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.65; }

.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }

.primary {
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 11px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 500;
  transition: background .15s, transform .06s;
}
.primary:hover { background: #0b5b47; }
.primary:active { transform: translateY(1px); }
.primary:disabled { opacity: .55; cursor: default; }
.primary.block { width: 100%; padding: 12px; margin-top: 8px; }

.ghost {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-2);
  border-radius: 11px;
  padding: 0 14px;
  white-space: nowrap;
  min-width: 110px;
  text-align: center;
  height: 40px;
  transition: border-color .15s, color .15s;
}
.ghost:hover { border-color: var(--brand-2); color: var(--brand); }
.ghost:disabled { opacity: .5; cursor: default; }
.ghost.small { padding: 7px 12px; font-size: 13px; }

/* 按钮状态类：只改样式不改 DOM 结构，避免宽度跳变 */
.ghost.is-busy {
  opacity: .55;
  cursor: default;
  border-color: var(--line-soft);
  color: var(--ink-3);
}
.ghost.is-sending {
  opacity: .6;
  cursor: wait;
}

.login-msg { height: 22px; line-height: 22px; margin: 10px 0 0; font-size: 13px; color: var(--danger); overflow: hidden; }
.login-note {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.75;
  color: var(--ink-3);
}

/* ---------- 后台框架（登录态时 #app 必须完全隐藏不占布局） ---------- */
.app { display: flex; min-height: 100%; }
#app.hidden { display: none !important; visibility: hidden !important; }

.side {
  width: 232px;
  flex: none;
  border-right: 1px solid var(--line);
  background: #fbfaf6;
  padding: 26px 16px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side .brand-row { padding: 0 10px 26px; }

#nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 14px;
  color: var(--ink-2);
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f2efe8; }
.nav-item.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 4px; }
.who { font-size: 12px; color: var(--ink-3); padding-left: 6px; }

.main { flex: 1; min-width: 0; padding: 34px 40px 60px; }
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: 0.3px; }
.page-head p { margin: 0; color: var(--ink-3); font-size: 13px; }

.content { display: flex; flex-direction: column; gap: 14px; max-width: 980px; }

/* ---------- 列表 ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .13s;
}
.row:last-child { border-bottom: none; }
.row:hover { background: #fbfaf6; }
.row:hover .row-edit { opacity: 1; }

.row-main { min-width: 0; flex: 1; }
.row-title { display: block; font-size: 14px; margin-bottom: 4px; }
.row-sub { display: block; font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }
.row-sub.clamp {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-chip {
  width: 40px; height: 40px;
  flex: none;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand);
}
.avatar-chip.amber { background: #fbf1e0; color: var(--amber); }
.avatar-chip.blue { background: #e9f0fa; color: #2f6b9e; }
.avatar-chip.pink { background: #fbecef; color: #a8506a; }
.avatar-chip.gray { background: #f1f0eb; color: #6b6a62; }

.row-ops { display: flex; align-items: center; gap: 10px; flex: none; }
.row-edit { opacity: 0; font-size: 12.5px; color: var(--ink-3); transition: opacity .15s; }

.switch {
  width: 42px; height: 24px;
  border-radius: 999px;
  background: #e3e0d7;
  border: none;
  position: relative;
  transition: background .18s;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
  transition: transform .18s;
}
.switch.on { background: var(--brand-2); }
.switch.on::after { transform: translateX(18px); }

.tag {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f0eb;
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.ok { background: var(--brand-soft); color: var(--brand); }
.tag.admin { background: #fbf1e0; color: var(--amber); }

.empty {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
  line-height: 1.8;
}

.loading {
  padding: 46px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}

/* ---------- 抽屉 ---------- */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(35, 36, 31, .22);
  backdrop-filter: blur(1.5px);
  z-index: 20;
}

.drawer {
  position: fixed;
  top: 0; right: 0;
  width: 440px;
  max-width: 100%;
  height: 100%;
  background: var(--card);
  border-left: 1px solid var(--line);
  z-index: 21;
  display: flex;
  flex-direction: column;
  box-shadow: -24px 0 60px -40px rgba(35, 36, 31, .4);
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 14px;
}
.drawer-head h2 { margin: 0; font-size: 17px; }
.icon-btn {
  border: none; background: transparent;
  font-size: 22px; line-height: 1;
  color: var(--ink-3);
  padding: 4px 6px;
  border-radius: 8px;
}
.icon-btn:hover { background: #f2efe8; color: var(--ink); }

.drawer-body { flex: 1; overflow-y: auto; padding: 4px 24px 20px; }
.drawer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--line-soft);
}

.danger-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--danger);
  border-radius: 11px;
  padding: 10px 16px;
}
.danger-ghost:hover { background: var(--danger-soft); border-color: #f0d5d1; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 4px;
  font-size: 13px;
  color: var(--ink-2);
}
.check-row input { width: auto; }

.hint-line { font-size: 12px; color: var(--ink-3); line-height: 1.7; margin: -6px 0 16px; }

/* ---------- 提示（右上角浮动，不挤布局） ---------- */
.toast {
  position: fixed;
  right: 20px;
  top: 20px;
  transform: translateY(-12px);
  background: #23241f;
  color: #fff;
  font-size: 13px;
  padding: 11px 18px;
  border-radius: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 40;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .side {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .side .brand-row { padding: 0; }
  #nav { flex-direction: row; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; }
  .who { display: none; }
  .main { padding: 20px 16px 40px; }
  .page-head h1 { font-size: 19px; }
  .drawer { width: 100%; }
}

/* ---------- 数据维护 ---------- */

/* ---------- 文案库 ---------- */
.copy-panel { display: flex; flex-direction: column; gap: 16px; }
.copy-add { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.copy-add .sync-title { margin: 0 0 4px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.copy-add input, .copy-add textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fdfdfb; font-size: 14px; box-sizing: border-box; }
.copy-add textarea { min-height: 110px; resize: vertical; line-height: 1.7; }
.copy-add .primary { align-self: flex-end; }
/* 客服绑定面板（B 方案手动绑） */
.kf-panel { display: flex; flex-direction: column; gap: 16px; }
.kf-add { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.kf-add .sync-title { margin: 0 0 4px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.kf-hint { margin: 0; font-size: 12px; line-height: 1.7; color: var(--ink-3); }
.kf-add select, .kf-add input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fdfdfb; font-size: 14px; box-sizing: border-box; }
.kf-add .primary { align-self: flex-end; }
.copy-list-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.copy-list { display: flex; flex-direction: column; gap: 10px; }
.copy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
}
.copy-row.off { opacity: .55; }
.copy-main { flex: 1; min-width: 0; }
.copy-row .row-title { display: block; margin-bottom: 4px; }
.copy-row .row-sub { display: block; font-size: 11.5px; color: var(--ink-3); }
.copy-preview { font-size: 13px; color: var(--ink-2); }
.copy-row .row-ops { display: flex; align-items: center; gap: 8px; flex: none; }
.copy-row .switch { width: 40px; height: 22px; border-radius: 999px; background: var(--line-soft); border: none; position: relative; cursor: pointer; flex: none; }
.copy-row .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15); transition: transform .2s; }
.copy-row .switch.on { background: var(--brand); }
.copy-row .switch.on::after { transform: translateX(18px); }

.data-panel { display: flex; flex-direction: column; gap: 18px; }
.data-pick { display: flex; align-items: flex-end; gap: 12px; }
.data-pick .field { flex: 1; margin-bottom: 0; }
.data-pick .field > span { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.data-pick select { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.data-pick .ghost { padding: 10px 16px; }

.panel-title { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 12px; }

.mat-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.mat-thead, .mat-trow {
  display: grid;
  grid-template-columns: 1.4fr .7fr .8fr .9fr .7fr .6fr .6fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
}
.mat-thead {
  background: #f7f5ef;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
  border-bottom: 1px solid var(--line);
}
.mat-trow { border-bottom: 1px solid var(--line-soft); }
.mat-trow:last-child { border-bottom: none; }
.mat-trow:hover { background: #fbfaf6; }
.tt-name { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tt-plat { color: var(--ink-2); }
.tt-num { font-variant-numeric: tabular-nums; color: var(--ink); }
.mat-del {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.mat-del:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.data-panel .sync { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.data-panel .sync-title { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.data-panel textarea { width: 100%; min-height: 80px; border: 1px solid var(--line); border-radius: 10px; padding: 10px; resize: vertical; }
.data-panel .sync-row { display: flex; gap: 10px; margin-top: 10px; }
.data-panel .sync-row select { width: 130px; padding: 8px; border: 1px solid var(--line); border-radius: 9px; }
.data-panel .sync-row .primary { flex: 1; }

.data-panel .parsed-wrap { margin-top: 12px; }
.data-panel .parsed-title { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.data-panel .parsed-list { max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; }
.data-panel .parsed-item { padding: 6px 0; border-bottom: 1px dashed var(--line-soft); }
.data-panel .parsed-item:last-child { border-bottom: none; }
.data-panel .parsed-line1 { display: flex; justify-content: space-between; align-items: center; }
.data-panel .parsed-name { font-size: 13px; font-weight: 500; }
.data-panel .parsed-spend { font-size: 13px; color: var(--brand-2); font-weight: 600; }

/* 成员「可见板块」复选框 */
.access-picks { display: flex; gap: 8px; flex-wrap: wrap; }
.access-picks .pick {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 13px; color: var(--ink-2);
  cursor: pointer; user-select: none; background: #fff;
}
.access-picks .pick:has(input:checked) {
  border-color: var(--brand); background: var(--brand-soft, #eef6f2); color: var(--brand-2);
}
.access-picks .pick input { margin: 0; }

/* ICP 备案号页脚 */
.icp-footer {
  text-align: center;
  padding: 24px 0 32px;
  font-size: 12px;
}
.icp-footer a {
  color: #9B9A92;
  text-decoration: none;
}
.icp-footer a:hover { color: #6B6A62; }
