:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1c1f23;
  --muted: #7a808a;
  --line: #e6e8ec;
  --primary: #2f6bff;
  --primary-dark: #2356d6;
  --green: #0f9f6e;
  --orange: #e8842c;
  --red: #d84343;
  --shadow: 0 2px 10px rgba(20, 30, 50, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  padding-bottom: 96px;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
code {
  background: #eef1f6;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-main { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand { font-size: 18px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.topbar-meta { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { margin: 0 4px; }
.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: .15s;
  line-height: 1.2;
}
.btn:hover { border-color: #c9ced8; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #f0f2f5; }

.notice {
  margin: 10px 16px 0;
  padding: 10px 12px;
  background: #fff7e8;
  border: 1px solid #f3d9a8;
  color: #8a5a10;
  border-radius: 8px;
  font-size: 13px;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 0;
  flex-wrap: wrap;
}
.control {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  outline: none;
}
.control:focus { border-color: var(--primary); }
#accountFilter { min-width: 180px; }
#searchInput { flex: 1 1 260px; min-width: 180px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; }
.toolbar-count { margin-left: auto; color: var(--muted); font-size: 12px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
  padding: 14px 16px 24px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s;
  content-visibility: auto;
  contain-intrinsic-size: 320px;
}
.card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(47, 107, 255, .12); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.pick { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; cursor: pointer; user-select: none; }
.pick input { width: 16px; height: 16px; accent-color: var(--primary); }
.head-badges { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #f0f2f5;
  color: #59606b;
  font-size: 11px;
  line-height: 1.5;
  white-space: nowrap;
}
.badge.hd { background: #e7f7ef; color: var(--green); font-weight: 600; }
.badge.new { background: #e8f0ff; color: var(--primary); font-weight: 600; }
.badge.commission { background: #fff3e6; color: var(--orange); font-weight: 600; }
.badge.done { background: #e7f7ef; color: var(--green); }
.badge.muted-badge { background: #f5f6f8; color: #a0a6b0; }

.card-body { display: flex; gap: 14px; padding: 12px; }
.thumb {
  width: 132px;
  height: 132px;
  border-radius: 10px;
  object-fit: cover;
  background: #eef0f3;
  flex-shrink: 0;
}
.nobg { display: flex; align-items: center; justify-content: center; color: #a5abb5; font-size: 12px; background: #eef0f3; }
.info { min-width: 0; flex: 1; }
.pname {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pid { color: var(--muted); font-size: 11px; margin-top: 3px; }
.seen { margin-left: 6px; color: #8a93a0; }
.metrics { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 7px; color: #59606b; font-size: 12px; }
.metrics strong { color: var(--text); }
.accounts { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 7px; }
.acc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 150px;
  padding: 2px 7px;
  background: #f5f7fa;
  border-radius: 6px;
  font-size: 11px;
  color: #59606b;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.acc em { font-style: normal; color: var(--muted); }
.acc.more { background: #eef1f6; }

.matbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 12px 12px;
  padding: 8px 10px;
  background: #f7f8fa;
  border-radius: 8px;
  font-size: 12px;
  color: #59606b;
}
.mat-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn.tiny { padding: 3px 10px; font-size: 12px; border-radius: 6px; flex-shrink: 0; }

body.modal-open { overflow: hidden; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-mask { position: absolute; inset: 0; background: rgba(15, 20, 30, .45); }
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(680px, calc(100vw - 32px));
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(10, 20, 40, .25);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.modal-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-close {
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}
.modal-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.modal-tools #modalCount { margin-left: auto; color: var(--muted); }
.modal-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.mitem {
  position: relative;
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  transition: .15s;
}
.mitem:hover { border-color: #c9ced8; }
.mitem.checked { border-color: var(--primary); background: #f5f8ff; }
.mitem input { position: absolute; opacity: 0; pointer-events: none; }
.mcover { width: 72px; height: 54px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: #eef0f3; }
.mmeta { min-width: 0; flex: 1; padding-right: 24px; }
.mtitle {
  font-size: 12px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vbadges { display: flex; gap: 3px; flex-wrap: wrap; margin-top: 3px; }
.vbadges .badge { padding: 1px 5px; font-size: 10px; }
.vlink {
  position: absolute;
  right: 6px;
  bottom: 6px;
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
  background: rgba(255, 255, 255, .92);
  padding: 1px 4px;
  border-radius: 4px;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.empty {
  margin: 40px auto;
  max-width: 460px;
  text-align: center;
  padding: 28px 20px;
  background: #fff;
  border: 1px dashed #d9dde5;
  border-radius: 12px;
}
.empty-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }

.bottombar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.selected-info { font-size: 14px; white-space: nowrap; }
.selected-info strong { font-size: 17px; }
#selectedCount { color: var(--primary); }
.bottom-actions { display: flex; align-items: center; gap: 12px; min-width: 0; }
.toast { color: var(--muted); font-size: 12px; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast.show.ok { color: var(--green); }
.toast.show.error { color: var(--red); }
.toast.show.info { color: #59606b; }

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(1200px 600px at 20% 0%, #e9f0ff 0%, #f4f5f7 55%, #f4f5f7 100%);
  padding-bottom: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(20, 30, 50, .1);
  padding: 28px 24px;
}
.login-logo { font-size: 13px; color: var(--primary); font-weight: 700; letter-spacing: 1px; }
.login-card h1 { margin: 6px 0 4px; font-size: 24px; }
.login-card p { margin: 0 0 16px; font-size: 13px; }
.login-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
}
.login-input:focus { border-color: var(--primary); }
.login-btn { width: 100%; padding: 11px; font-size: 15px; }
.alert { padding: 9px 11px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert.error { background: #fff0f0; color: var(--red); border: 1px solid #f5c9c9; }

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; padding: 12px 10px 20px; gap: 10px; }
  .topbar { padding: 8px 10px; flex-wrap: wrap; }
  .topbar-main { width: 100%; }
  .topbar-actions { width: 100%; justify-content: flex-end; }
  .toolbar { padding: 10px 10px 0; gap: 8px; }
  #accountFilter { flex: 1 1 100%; }
  #searchInput { flex: 1 1 100%; }
  .toolbar-count { margin-left: 0; }
  .bottombar { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .bottom-actions { width: 100%; justify-content: space-between; }
  .toast { max-width: 55vw; }
  .thumb { width: 104px; height: 104px; }
  .modal { align-items: flex-end; }
  .modal-panel {
    width: 100%;
    max-width: none;
    max-height: 84vh;
    border-radius: 14px 14px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .modal-list { grid-template-columns: 1fr; }
}
