:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --surface-3: #e5edf5;
  --text: #17202a;
  --muted: #667381;
  --line: #d9e2ec;
  --brand: #1677ff;
  --brand-strong: #0b5ed7;
  --green: #0f8a5f;
  --red: #c2413b;
  --amber: #a15c00;
  --shadow: 0 12px 30px rgba(31, 45, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
}

.sidebar {
  min-height: 100vh;
  padding: 22px 16px;
  background: #101820;
  color: #f7fafc;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #2dd4bf, #1677ff);
  color: #ffffff;
  font-weight: 800;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
}

.brand-subtitle {
  color: #9fb0c0;
  font-size: 12px;
  margin-top: 3px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: #c8d3dd;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.nav button:hover,
.nav button.active {
  background: #1b2835;
  color: #ffffff;
}

.nav svg,
.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.account-mini {
  padding: 12px;
  border-radius: 8px;
  background: #172330;
  color: #d8e2eb;
  overflow-wrap: anywhere;
}

.account-mini strong {
  display: block;
  font-size: 13px;
  color: #ffffff;
}

.account-mini span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #aebdca;
}

.main {
  min-width: 0;
  padding: 24px;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.3;
}

h3 {
  font-size: 15px;
  line-height: 1.3;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.grid {
  display: grid;
  gap: 16px;
}

.metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  min-height: 116px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  align-content: space-between;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: 30px;
  line-height: 1;
}

.metric-bar {
  height: 6px;
  width: 100%;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.metric-bar i {
  display: block;
  height: 100%;
  width: var(--value, 0%);
  background: var(--brand);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.panel-body {
  padding: 18px;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.form-row {
  display: grid;
  gap: 6px;
}

label {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.12);
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-2);
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-3);
}

.btn.primary {
  background: var(--brand);
  color: #ffffff;
}

.btn.primary:hover {
  background: var(--brand-strong);
}

.btn.danger {
  background: #fff1f0;
  color: var(--red);
}

.btn.ghost {
  background: transparent;
  color: inherit;
}

.btn.icon-only {
  width: 38px;
  min-height: 38px;
  padding: 0;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 700;
  background: #fbfcfe;
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.green {
  color: var(--green);
  background: #ecfdf5;
}

.badge.red {
  color: var(--red);
  background: #fff1f0;
}

.badge.amber {
  color: var(--amber);
  background: #fff7e6;
}

.code {
  max-width: 540px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: #0f172a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  overflow-x: auto;
}

pre.code {
  max-width: none;
  max-height: 360px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.market {
  display: grid;
  gap: 28px;
}

.market-hero {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 8px 0 0;
  text-align: center;
}

.market-hero > span {
  color: #4f46e5;
  font-size: 13px;
  font-weight: 700;
}

.market-hero h2 {
  font-size: 30px;
  line-height: 1.2;
}

.market-hero p {
  color: var(--muted);
}

.market-search {
  width: min(680px, 100%);
  height: 48px;
  margin-top: 28px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 20px rgba(31, 45, 61, 0.04);
}

.market-search span {
  color: #8a99aa;
  font-size: 24px;
  line-height: 1;
}

.market-search input {
  min-height: 0;
  border: 0;
  padding: 0;
  box-shadow: none;
}

.market-search input:focus {
  box-shadow: none;
}

.market-chip-row {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.market-chip-title {
  color: var(--muted);
  font-size: 12px;
}

.market-chips {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  max-width: 980px;
}

.market-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  color: #243244;
  box-shadow: 0 4px 12px rgba(31, 45, 61, 0.06);
  cursor: pointer;
}

.market-chip:hover,
.market-chip.active {
  border-color: #111827;
  background: #111827;
  color: #ffffff;
}

.market-chip-mark,
.platform-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: inline-grid;
  place-items: center;
  background: #eef3f8;
  color: #476174;
  font-size: 10px;
  font-weight: 800;
}

.market-chip.active .market-chip-mark {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.platform-mark.youtube,
.market-chip-mark.youtube {
  background: #ff2b2b;
  color: #ffffff;
}

.platform-mark.bilibili,
.market-chip-mark.bilibili {
  background: #e7f7ff;
  color: #087ea4;
}

.platform-mark.douyin,
.market-chip-mark.douyin,
.platform-mark.tiktok,
.market-chip-mark.tiktok {
  background: #111827;
  color: #ffffff;
}

.platform-mark.instagram,
.market-chip-mark.instagram {
  background: #fff0f6;
  color: #d6336c;
}

.platform-mark.wechat,
.market-chip-mark.wechat {
  background: #ecfdf5;
  color: #0f8a5f;
}

.market-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.market-segment {
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef1f5;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.market-segment button {
  min-width: 58px;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 13px;
  color: #526171;
  background: transparent;
  cursor: pointer;
}

.market-segment button.active {
  color: #ffffff;
  background: #111827;
}

.market-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.market-card {
  min-height: 174px;
  padding: 26px 22px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  text-align: left;
  display: grid;
  align-content: start;
  gap: 10px;
  color: var(--text);
  cursor: pointer;
}

.market-card:hover {
  background: #ffffff;
  box-shadow: inset 0 0 0 1px #b9d6ff;
}

.market-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.method-badge {
  min-height: 24px;
  border-radius: 7px;
  padding: 3px 8px;
  background: #dbeafe;
  color: #2563eb;
  font-size: 12px;
  font-weight: 800;
  margin-left: auto;
}

.market-card-path {
  color: #0f172a;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.market-card-desc {
  color: #526171;
  font-size: 13px;
  line-height: 1.45;
}

.market-card-meta {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #526171;
  font-size: 12px;
}

.market-card-meta strong {
  color: #111827;
  font-size: 13px;
}

.market-empty {
  grid-column: 1 / -1;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.market-detail {
  display: grid;
  gap: 20px;
}

.market-back {
  width: max-content;
  color: #526171;
}

.market-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.market-detail-head h2 {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.market-desc {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8f7f5;
}

.market-desc summary {
  min-height: 44px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 700;
}

.market-desc p {
  padding: 0 18px 16px;
  color: var(--muted);
}

.market-detail-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 360px;
  gap: 20px;
}

.market-param-panel,
.market-response-panel,
.market-ai-panel {
  min-height: 510px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfaf8;
  overflow: hidden;
}

.market-param-panel {
  padding: 18px;
}

.market-response-panel {
  padding: 18px;
  display: grid;
}

.market-response-empty {
  display: grid;
  place-items: center;
  min-height: 460px;
  color: #8a99aa;
  text-align: center;
}

.market-response {
  display: grid;
  gap: 14px;
  align-content: start;
}

.market-ai-body {
  min-height: 445px;
  padding: 38px 16px 16px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 12px;
  text-align: center;
}

.assistant-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #ede9fe;
  color: #6d5dfc;
  font-weight: 800;
}

.ai-prompts {
  width: 100%;
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.ai-prompts button,
.ai-input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #8a99aa;
}

.ai-input {
  width: 100%;
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: center;
  padding: 4px;
}

.ai-input input {
  min-height: 32px;
  border: 0;
  box-shadow: none;
}

.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--muted);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  background: var(--surface);
}

.auth-panel {
  padding: 42px;
  display: grid;
  align-content: center;
  gap: 24px;
}

.auth-visual {
  min-height: 100vh;
  padding: 46px;
  background:
    linear-gradient(rgba(16, 24, 32, 0.72), rgba(16, 24, 32, 0.72)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='900' viewBox='0 0 1200 900'%3E%3Crect width='1200' height='900' fill='%23101820'/%3E%3Cg fill='none' stroke='%232dd4bf' stroke-opacity='.35'%3E%3Cpath d='M90 178h280c42 0 76 34 76 76v62c0 42 34 76 76 76h158c42 0 76 34 76 76v108c0 42 34 76 76 76h278'/%3E%3Cpath d='M112 650h210c38 0 70-31 70-70v-92c0-38 31-70 70-70h246c38 0 70-31 70-70v-88c0-38 31-70 70-70h240'/%3E%3C/g%3E%3Cg fill='%23ffffff' fill-opacity='.9'%3E%3Ccircle cx='90' cy='178' r='9'/%3E%3Ccircle cx='446' cy='316' r='9'/%3E%3Ccircle cx='756' cy='576' r='9'/%3E%3Ccircle cx='1110' cy='652' r='9'/%3E%3Ccircle cx='112' cy='650' r='9'/%3E%3Ccircle cx='778' cy='260' r='9'/%3E%3C/g%3E%3Cg fill='%231677ff' fill-opacity='.4'%3E%3Crect x='122' y='238' width='190' height='96' rx='8'/%3E%3Crect x='484' y='458' width='230' height='118' rx='8'/%3E%3Crect x='836' y='164' width='210' height='112' rx='8'/%3E%3C/g%3E%3C/svg%3E");
  background-size: cover;
  color: #ffffff;
  display: grid;
  align-content: end;
}

.auth-visual h1 {
  max-width: 720px;
  font-size: 42px;
}

.auth-visual p {
  max-width: 620px;
  margin-top: 14px;
  color: #d8e2eb;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 8px;
  background: var(--surface-2);
}

.auth-tabs button {
  min-height: 38px;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
}

.auth-tabs button.active {
  background: #ffffff;
  color: var(--text);
  box-shadow: 0 6px 16px rgba(31, 45, 61, 0.08);
}

.secret-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #b7eb8f;
  background: #f6ffed;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #101820;
  color: #ffffff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

  .split {
    grid-template-columns: 1fr;
  }

  .market-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .market-detail-grid {
    grid-template-columns: 1fr;
  }

  .market-param-panel,
  .market-response-panel,
  .market-ai-panel {
    min-height: auto;
  }
}

@media (max-width: 820px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 14px;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav button {
    justify-content: center;
  }

  .nav span {
    display: none;
  }

  .sidebar-footer {
    display: none;
  }

  .main {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none;
  }
}

@media (max-width: 560px) {
  .metrics,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 24px;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .market-grid {
    grid-template-columns: 1fr;
  }

  .market-hero h2 {
    font-size: 24px;
  }

  .market-chips,
  .market-filters {
    justify-content: flex-start;
  }
}
