:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --text: #1c2430;
  --dim: #5a6574;
  --mute: #8a93a0;
  --line: rgba(28, 36, 48, 0.08);
  --line2: rgba(28, 36, 48, 0.14);
  --accent: #2f5cff;
  --accent-deep: #1e45d4;
  --warn: #b7791f;
  --danger: #c53d3d;
  --ok: #2a7a4b;
  --shadow: 0 10px 24px rgba(24, 32, 48, 0.06);
  --radius: 12px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: linear-gradient(180deg, #f6f7f9 0%, #eef0f4 100%);
  overflow: hidden;
}

.shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.auth-screen {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  overflow: auto;
  background: radial-gradient(ellipse at 12% 12%, rgba(80, 125, 255, .16), transparent 34%),
    radial-gradient(ellipse at 88% 86%, rgba(99, 77, 210, .12), transparent 32%),
    linear-gradient(145deg, #f6f8ff 0%, #edf1fb 52%, #f6f5fc 100%);
}
.auth-card {
  width: min(100%, 420px); padding: 38px 40px 28px; display: grid; gap: 18px;
  background: rgba(255,255,255,.94); border: 1px solid rgba(255,255,255,.9); border-radius: 22px;
  box-shadow: 0 24px 70px rgba(36, 54, 105, .13), 0 2px 8px rgba(36, 54, 105, .04);
  backdrop-filter: blur(14px);
}
.auth-brand { display: flex; align-items: center; gap: 11px; color: #65718b; font-size: 13px; font-weight: 650; letter-spacing: .04em; }
.auth-mark {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px;
  color: white; font-size: 18px; font-weight: 750;
  background: linear-gradient(145deg, #547cff, #3452d9); box-shadow: 0 6px 14px rgba(54, 86, 220, .25);
}
.auth-heading { margin: 8px 0 2px; }
.auth-card h1 { margin: 0 0 8px; color: #18233e; font-size: 27px; line-height: 1.25; letter-spacing: -.03em; }
.auth-card p { margin: 0; color: #78839b; font-size: 14px; line-height: 1.6; }
.auth-card label { display: grid; gap: 8px; color: #505d77; font-size: 13px; font-weight: 600; }
.auth-card input {
  width: 100%; height: 48px; padding: 0 14px; border: 1px solid #dfe4ef; border-radius: 11px;
  background: #fbfcff; font: inherit; font-size: 14px; color: #202b45; outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.auth-card input::placeholder { color: #a7afbf; }
.auth-card input:hover { border-color: #c8d1e4; }
.auth-card input:focus { border-color: #5478f6; background: white; box-shadow: 0 0 0 4px rgba(75, 111, 241, .12); }
.auth-error { min-height: 2px; margin-top: -8px; color: #c13d52; font-size: 13px; }
.auth-submit { width: 100%; min-height: 48px; margin-top: -4px; border: 0; border-radius: 11px; font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.auth-submit.btn.primary { background: linear-gradient(110deg, #5278f6 0%, #3c5ee5 55%, #344fd1 100%); box-shadow: 0 9px 18px rgba(58, 87, 210, .22); }
.auth-submit.btn.primary:hover { box-shadow: 0 12px 22px rgba(58, 87, 210, .3); }
.auth-submit:disabled { opacity: .65; cursor: wait; transform: none; }
.auth-switch { justify-self: center; border: 0; background: transparent; color: #4c68d5; cursor: pointer; padding: 3px 8px; font: inherit; font-size: 13px; font-weight: 600; }
.auth-switch:hover { color: #304dc3; }
.auth-switch span { display: inline-block; margin-left: 3px; transition: transform .15s; }
.auth-switch:hover span { transform: translateX(3px); }
.auth-footnote { padding-top: 16px; border-top: 1px solid #edf0f6; color: #9aa3b5; text-align: center; font-size: 12px; }
@media (max-width: 480px) { .auth-card { padding: 30px 24px 22px; border-radius: 18px; } }
body.authenticated .auth-screen { display: none; }
body.authenticated .shell { display: flex; }

.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px;
  background: linear-gradient(145deg, #3a5fff, #1c2430);
}
.brand-text h1 { margin: 0; font-size: 15px; letter-spacing: -0.02em; line-height: 1.2; }
.brand-text p { margin: 2px 0 0; color: var(--mute); font-size: 11px; }

.tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--dim);
  padding: 8px 14px;
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: .15s ease;
}
.tab:hover { background: rgba(28, 36, 48, 0.05); color: var(--text); }
.tab.active {
  background: #eef1ff;
  color: var(--accent-deep);
}
.top-note {
  flex: 0 0 auto;
  color: var(--mute);
  font-size: 11px;
  max-width: 220px;
  text-align: right;
  line-height: 1.35;
}

.main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 16px 18px 20px;
}

.page { display: none; }
.page.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: min-content;
}
#page-creators.active {
  min-height: calc(100vh - var(--topbar-h) - 36px);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
.page.active { animation: rise .22s ease; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.page-head h2 { margin: 0; font-size: 20px; letter-spacing: -0.03em; }
.page-head p { margin: 4px 0 0; color: var(--dim); font-size: 12px; }
.page-head code {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #f0f2f6;
  color: var(--dim);
}
.channel-field { min-width: 260px; }
.channel-checks {
  display: flex; flex-wrap: wrap; gap: 8px 14px;
  align-items: center; min-height: 36px;
  padding: 4px 0;
}
.chk {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text); cursor: pointer; user-select: none;
}
.chk input { width: auto; margin: 0; accent-color: #2f5cff; }
.import-chs { margin: 0 0 10px; }
.ch-cell { white-space: normal; }
.tag-chk {
  display: inline-flex; align-items: center; gap: 3px;
  margin: 2px 4px 2px 0; padding: 2px 7px;
  border: 1px solid var(--line2); border-radius: 999px;
  font-size: 11px; color: var(--mute); background: #f5f6f8; cursor: pointer;
}
.tag-chk.on {
  color: #1d4ed8; background: #eff4ff; border-color: #bfdbfe;
}
.tag-chk input { width: auto; margin: 0; accent-color: #2f5cff; }
.brand-text h1 { font-size: 15px; }

.card {
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  padding: 12px 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; min-width: 130px; }
.field.grow { flex: 1; min-width: 160px; }
.field.block { width: 100%; max-width: 640px; }
.field span { font-size: 12px; color: var(--mute); }
.field input, .field select, textarea, input, select {
  width: 100%; border: 1px solid var(--line2); background: #fff;
  border-radius: 9px; padding: 8px 11px; font: inherit; color: var(--text); outline: none;
}
.field input:focus, .field select:focus, textarea:focus {
  border-color: rgba(47, 92, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(47, 92, 255, 0.1);
}

.btn {
  border: 1px solid transparent; border-radius: 10px;
  padding: 8px 14px; font: inherit; font-weight: 650; cursor: pointer;
  transition: .15s ease; white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:not(:disabled):hover { transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, #3a5fff, #1e45d4);
  color: #fff; box-shadow: 0 6px 14px rgba(47, 92, 255, 0.2);
}
.btn.ghost { background: #fff; border-color: var(--line2); color: var(--text); }
.btn.danger {
  background: rgba(197, 61, 61, 0.08); border-color: rgba(197, 61, 61, 0.25); color: #b13333;
  padding: 6px 10px; border-radius: 8px; font-size: 12px;
}

.quick-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
}
.quick-label {
  font-size: 12px;
  color: var(--mute);
  margin-right: 2px;
}
.chip {
  border: 1px solid var(--line2);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: .15s ease;
}
.chip:hover { border-color: rgba(47, 92, 255, 0.35); color: var(--accent-deep); }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.chip.active {
  border-color: rgba(47, 92, 255, 0.45);
  background: #eef1ff;
  color: var(--accent-deep);
}

.period-banner {
  padding: 2px 2px;
  font-size: 12px;
  color: var(--dim);
}
.period-banner strong { color: var(--text); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stat {
  padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: #fff;
}
.stat .k { color: var(--mute); font-size: 11px; }
.stat .v { margin-top: 4px; font-size: 18px; font-weight: 750; letter-spacing: -0.03em; }
.stat.accent .v { color: var(--accent-deep); }

.progress { padding: 10px 14px; }
.progress-meta { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; margin-bottom: 6px; }
.track { height: 7px; border-radius: 999px; background: rgba(28, 36, 48, 0.08); overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #1e45d4, #3a5fff, #6b8cff);
  transition: width .2s ease;
}

.panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel.grow {
  flex: 1 1 auto;
  min-height: 220px;
}
.panel.pad { padding: 16px; gap: 12px; }
.panel-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc;
  flex: 0 0 auto;
}
.panel-bar.clickable {
  cursor: pointer;
  user-select: none;
}
.panel-bar.clickable:hover { background: #f0f3fa; }
.panel-bar h3, .mini { margin: 0; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.panel-bar-right { display: flex; align-items: center; gap: 10px; }
.collapse-hint { font-size: 12px; color: var(--mute); font-weight: 500; }
.caret {
  display: inline-block;
  width: 1em;
  transition: transform .15s ease;
  color: var(--mute);
}
.panel.collapsible.collapsed .panel-bar { border-bottom: 0; }
.panel.collapsible.collapsed .collapse-body { display: none; }
.panel.collapsible:not(.collapsed) .caret { transform: rotate(90deg); }
.table-wrap {
  overflow: auto;
  max-height: 260px;
}
#page-creators .table-wrap {
  max-height: none;
  flex: 1 1 auto;
  min-height: 180px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #f3f4f7; color: var(--mute); font-size: 12px; font-weight: 600; z-index: 1; }
tbody tr:hover { background: rgba(47, 92, 255, 0.04); }
.num { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right !important; }
.empty-row td { text-align: center !important; color: var(--mute); padding: 28px 12px; }
.ok { color: var(--ok); }
.err { color: var(--danger); }

.summary-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 10px;
}
.summary-grid .table-wrap { max-height: 220px; }

.badge {
  margin-left: 0; font-size: 11px; padding: 2px 7px; border-radius: 999px;
  border: 1px solid var(--line2); background: #f5f6f8; color: var(--dim);
}
.badge.soft { margin-left: 0; }
.row { display: flex; align-items: center; }
.row.gap { gap: 10px; }
.row.end { justify-content: flex-end; }
.muted { color: var(--dim); font-size: 13px; line-height: 1.7; margin: 8px 0 0; }
.hint-block { color: var(--dim); font-size: 13px; line-height: 1.7; margin: 8px 0 0; }
code { font-family: Consolas, monospace; font-size: 12px; }
.hidden { display: none !important; }

.modal {
  position: fixed; inset: 0; background: rgba(20, 26, 36, 0.32);
  display: grid; place-items: center; z-index: 50; backdrop-filter: blur(3px);
}
.modal-card {
  width: min(560px, calc(100vw - 40px));
  background: #fff; border-radius: 14px; border: 1px solid var(--line2);
  box-shadow: 0 22px 56px rgba(24, 32, 48, 0.16); padding: 20px;
}
.modal-card h3 { margin: 0 0 8px; }
.modal-card p { margin: 0 0 12px; color: var(--dim); font-size: 13px; }
.modal-card textarea { width: 100%; resize: vertical; margin-bottom: 14px; }

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  min-width: 200px; max-width: 360px; padding: 11px 13px;
  border-radius: 11px; border: 1px solid var(--line2); background: #fff;
  box-shadow: var(--shadow);
}
.toast.ok { border-color: rgba(47, 92, 255, 0.28); background: #f5f7ff; }
.toast.err { border-color: rgba(197, 61, 61, 0.3); background: #fff6f6; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .top-note { display: none; }
}
