:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e7e9f2;
  --bg: #f6f7fb;
  --card: #ffffff;
  --sidebar: #12142a;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

/* ---------- 登录 ---------- */
.login-screen {
  position: relative;
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background: radial-gradient(120% 100% at 50% 0%, #1c1f3d 0%, #0b0d1c 55%, #070812 100%);
}

.login-glow {
  position: absolute;
  width: 620px;
  height: 620px;
  top: -260px;
  left: 50%;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(99, 102, 241, 0.45), rgba(124, 58, 237, 0.12) 45%, transparent 70%);
  filter: blur(10px);
  pointer-events: none;
}

.login-card {
  position: relative;
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 22px;
  padding: 34px 32px 28px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.login-brand div {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.login-brand span {
  color: var(--muted);
  font-size: 12px;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.login-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbfe;
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.input:focus {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.btn-block {
  width: 100%;
  margin-top: 6px;
}

.login-error {
  margin: 0 0 10px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fee2e2;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
}

.login-foot {
  margin: 18px 0 0;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
}

/* ---------- 布局 ---------- */
.app {
  display: flex;
  min-height: 100%;
}

.sidebar {
  width: 236px;
  flex: none;
  background: var(--sidebar);
  color: #c7cbe0;
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px 22px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  box-shadow: 0 6px 18px -6px rgba(99, 102, 241, 0.9);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  color: #fff;
}

.brand-text strong {
  font-size: 15px;
  letter-spacing: 0.02em;
}

.brand-text span {
  font-size: 11px;
  color: #8a90b4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #a9aecb;
  text-decoration: none;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.28), rgba(124, 58, 237, 0.14));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.28);
}

.nav-icon {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  opacity: 0.9;
}

.nav-icon svg {
  width: 17px;
  height: 17px;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.foot-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.foot-card strong {
  display: block;
  font-size: 12px;
  color: #e2e8ff;
  font-weight: 600;
}

.foot-card span:last-child {
  font-size: 11px;
  color: #8a90b4;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.14);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 40px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-title {
  margin: 0;
  font-size: 21px;
  letter-spacing: -0.02em;
}

.page-sub {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* ---------- 组件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.06s, background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(140deg, var(--brand), var(--brand-2));
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(79, 70, 229, 0.9);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: #334155;
}

.btn-ghost:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.btn-danger {
  background: var(--danger-bg);
  border-color: #fecaca;
  color: var(--danger);
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

.sidebar .btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.09);
  color: #cbd2f0;
}

.sidebar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

.stat-hint {
  color: #94a3b8;
  font-size: 12px;
  margin-top: 2px;
}

.stat-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #eef2ff;
  color: var(--brand);
}

.stat-ico svg {
  width: 15px;
  height: 15px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.panel-sub {
  color: var(--muted);
  font-size: 12px;
  margin: 1px 0 0;
}

.panel-body {
  padding: 18px;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.toolbar .input {
  height: 34px;
  width: 220px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th {
  text-align: left;
  padding: 10px 18px;
  color: #94a3b8;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: #fafbfe;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 12px 18px;
  border-bottom: 1px solid #f1f3f9;
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #fafbff;
}

.table tr.row-selected {
  background: #f2f5ff;
}

.check-col {
  width: 42px;
  padding-right: 0 !important;
}

.check-col input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--brand);
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.file-ico {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 8px;
  background: #eef2ff;
  color: var(--brand);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}

.cell-name strong {
  display: block;
  font-weight: 600;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-name span {
  color: #94a3b8;
  font-size: 11.5px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.muted {
  background: #f1f5f9;
  color: #64748b;
}

.mono {
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #475569;
}

.nowrap {
  white-space: nowrap;
}

.empty {
  padding: 46px 20px;
  text-align: center;
  color: #94a3b8;
}

.empty strong {
  display: block;
  color: #475569;
  margin-bottom: 4px;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

.pager-actions {
  display: flex;
  gap: 6px;
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 190px;
  padding: 8px 4px 0;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
  justify-content: flex-end;
}

.chart-bar {
  width: 100%;
  max-width: 46px;
  border-radius: 7px 7px 4px 4px;
  background: linear-gradient(180deg, #818cf8, #4f46e5);
  min-height: 4px;
  transition: height 0.3s ease;
}

.chart-bar.zero {
  background: #eef0f8;
}

.chart-label {
  color: #94a3b8;
  font-size: 11px;
  white-space: nowrap;
}

.chart-value {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  font-variant-numeric: tabular-nums;
}

.split {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
}

.usage {
  height: 6px;
  border-radius: 999px;
  background: #eef0f8;
  overflow: hidden;
  margin-top: 6px;
  width: 120px;
}

.usage > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.6);
  z-index: 50;
  max-width: 90vw;
}

.toast.error {
  background: #b91c1c;
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(540px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
  animation: pop 0.18s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  border: none;
  background: transparent;
  font-size: 16px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
}

.modal-close:hover {
  background: #f1f5f9;
  color: #475569;
}

.modal-body {
  padding: 18px 22px;
}

.modal-body .field {
  margin-bottom: 12px;
}

.modal-body .input {
  height: 38px;
  background: #fff;
}

.modal-body textarea.input {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.6;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: #fff;
}

.select {
  width: 118px;
  height: 34px;
  padding: 0 8px;
  font-size: 13px;
  color: #334155;
}

.file-input {
  height: auto;
  padding: 7px 10px;
  font-size: 13px;
  background: #fbfbfe;
}

.check-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 2px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #334155;
}

.modal-hint {
  margin: 8px 0 0;
  min-height: 16px;
  color: var(--muted);
  font-size: 12px;
}

.progress {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: #eef0f8;
  overflow: hidden;
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
  transition: width 0.2s ease;
}

.modal-file {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.modal-file strong {
  font-size: 13px;
}

.modal-file span {
  color: var(--muted);
  font-size: 12px;
}

/* ---------- 公众号投放 ---------- */
.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.copy-row .input {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
}

.qr-box {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 190px;
  margin: 10px 0;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fbfbfe;
}

.qr-img {
  width: 180px;
  height: 180px;
  border-radius: 8px;
}

.promote-warn {
  color: #b45309;
  font-size: 12.5px;
  line-height: 1.7;
}

.hint-text {
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- 批量上传 ---------- */
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.file-chip {
  max-width: 100%;
  padding: 4px 10px;
  border-radius: 8px;
  background: #eef1ff;
  color: #4338ca;
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-picker {
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfbfe;
}

.doc-pick-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.doc-pick-item:hover {
  background: #eef1ff;
}

.doc-pick-item span {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-pick-item em {
  flex: none;
  font-style: normal;
  color: var(--muted);
  font-size: 11.5px;
}

.coll-option {
  margin: 10px 0 2px;
  padding: 12px;
  border: 1px dashed #c7d2fe;
  border-radius: 10px;
  background: #f5f7ff;
}

.coll-option .check {
  margin-bottom: 8px;
}

.coll-option .input {
  width: 100%;
}

@media (max-width: 1080px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .split {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app {
    flex-direction: column;
  }
  .sidebar {
    width: auto;
    height: auto;
    position: static;
    padding: 14px 14px 10px;
  }
  .brand {
    padding-bottom: 12px;
  }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }
  .nav-item {
    padding: 7px 10px;
  }
  .sidebar-foot {
    display: none;
  }
  .main {
    padding: 18px 14px 30px;
  }
  .grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-value {
    font-size: 21px;
  }
  .toolbar .input {
    width: 140px;
  }
  .table th,
  .table td {
    padding: 10px 12px;
  }
}
