:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --ink: #111827;
  --muted: #667085;
  --line: #d7dce5;
  --panel: #ffffff;
  --panel-soft: #f9fafb;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b45309;
  --violet: #5b21b6;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

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

[hidden] {
  display: none !important;
}

.loading-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.pulse {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(37, 99, 235, 0.18);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 32px;
  background:
    linear-gradient(rgba(7, 12, 21, 0.56), rgba(7, 12, 21, 0.32)),
    url("https://images.unsplash.com/photo-1497366754035-f200968a6e72?auto=format&fit=crop&w=1800&q=80")
      center / cover;
}

.login-hero {
  width: min(760px, 100%);
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-hero .eyebrow {
  color: rgba(255, 255, 255, 0.76);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

.login-hero h1 {
  max-width: 620px;
  font-size: clamp(44px, 9vw, 96px);
  line-height: 0.95;
}

.login-copy {
  max-width: 620px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.84);
  font-size: 18px;
  line-height: 1.7;
}

.login-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 32px;
}

.primary-action,
.secondary-action,
.ghost-action,
.chat-form button,
.quick-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
}

.primary-action {
  background: #fff;
  color: #111827;
  font-weight: 750;
}

.secondary-action {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.ghost-action {
  border-color: var(--line);
  color: var(--ink);
  background: var(--panel-soft);
}

.muted {
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar,
.status-band,
.panel-heading,
.user-block,
.quick-actions,
.chat-form {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.topbar h1 {
  font-size: clamp(28px, 5vw, 44px);
}

.user-block {
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-block img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #e5e7eb;
}

.user-block strong,
.user-block span {
  display: block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.status-band {
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid #b7ded9;
  border-radius: 8px;
  background: #ecfdf5;
  margin-bottom: 18px;
}

.status-band p {
  margin: 4px 0 0;
  color: #475467;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--teal);
}

.panel,
.module-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel h2 {
  font-size: 22px;
}

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

.module-item {
  display: flex;
  min-height: 148px;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: none;
  padding: 15px;
}

.module-item.clickable {
  cursor: pointer;
}

.module-item.clickable:hover {
  border-color: var(--blue);
}

.module-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.module-item strong {
  display: block;
  min-width: 0;
  font-size: 16px;
  line-height: 1.35;
}

.module-item p {
  margin: 10px 0 12px;
  color: var(--muted);
  line-height: 1.55;
}

.module-item .tag {
  display: inline-flex;
  flex: 0 0 auto;
  padding: 3px 9px;
  border-radius: 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.module-action {
  align-self: flex-start;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
}

.module-action:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.72;
}

.tag.live {
  background: var(--teal);
}

.tag.next {
  background: var(--blue);
}

.tag.research {
  background: var(--amber);
}

.tag.risk {
  background: var(--danger);
}

.agent-panel {
  position: sticky;
  top: 18px;
}

.quick-actions {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.quick-actions button {
  min-height: 36px;
  border-color: var(--line);
  background: var(--panel-soft);
  color: var(--ink);
}

.chat-output {
  min-height: 260px;
  max-height: 420px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  line-height: 1.65;
  white-space: pre-wrap;
}

.chat-output:empty::before {
  content: "可以先点快捷指令，或直接让它整理财务、订阅、服务器、域名相关事项。";
  color: #94a3b8;
}

.chat-form {
  align-items: stretch;
  gap: 10px;
  margin-top: 12px;
}

.chat-form textarea {
  flex: 1;
  min-height: 86px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
}

.chat-form button {
  align-self: stretch;
  min-width: 86px;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
}

.data-panel {
  margin-top: 18px;
}

.finance-workspace {
  margin-bottom: 18px;
}

.finance-tabs,
.finance-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.finance-tabs {
  margin-bottom: 14px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.finance-tabs button,
.primary-inline {
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.finance-tabs button {
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.finance-tabs button.active,
.primary-inline {
  background: var(--ink);
  color: #fff;
}

.finance-status {
  min-height: 24px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 14px;
}

.finance-status strong {
  color: var(--ink);
}

.finance-tab-panel {
  display: none;
}

.finance-tab-panel.active {
  display: block;
}

.finance-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.finance-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.finance-form label span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.finance-form input,
.finance-form select,
.finance-form textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

.finance-form textarea {
  resize: vertical;
}

.finance-form .wide {
  grid-column: span 2;
}

.finance-form button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.manual-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.api-manager {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.api-manager summary {
  min-height: 42px;
  padding: 11px 13px;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.api-manager .finance-form {
  margin: 0;
  padding: 0 13px 13px;
}

.research-list {
  display: grid;
  gap: 10px;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.research-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.research-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.research-card strong {
  line-height: 1.35;
}

.research-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.research-card small,
.score-pill {
  color: var(--muted);
  font-size: 12px;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 750;
  white-space: nowrap;
}

.compact .research-card {
  background: #fff;
}

.source-card {
  min-height: 220px;
}

.source-links,
.api-env-list,
.api-key-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mini-link,
.env-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}

.mini-link:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.env-chip {
  gap: 8px;
  color: var(--muted);
}

.env-chip.configured {
  border-color: rgba(15, 118, 110, 0.24);
  background: #ecfdf3;
  color: var(--teal);
}

.env-chip button {
  min-height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--danger);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.env-chip button:disabled {
  color: #98a2b3;
  cursor: not-allowed;
}

.api-key-form {
  display: grid;
  grid-template-columns: minmax(150px, 0.85fr) minmax(180px, 1fr) auto;
  align-items: center;
}

.api-key-form select,
.api-key-form input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.api-key-form button {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 750;
  cursor: pointer;
}

.memo-box {
  min-height: 180px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e5e7eb;
  line-height: 1.65;
  white-space: pre-wrap;
}

.memo-box:empty::before {
  content: "暂无内容";
  color: #94a3b8;
}

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

.roadmap div {
  min-height: 96px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.roadmap strong {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: var(--violet);
  color: #fff;
}

.roadmap span {
  display: block;
  color: #475467;
  line-height: 1.55;
}

@media (max-width: 980px) {
  .workspace-grid,
  .finance-form,
  .api-key-form,
  .source-grid,
  .roadmap {
    grid-template-columns: 1fr;
  }

  .finance-form .wide {
    grid-column: span 1;
  }

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

  .agent-panel {
    position: static;
  }
}

@media (max-width: 680px) {
  .app-shell,
  .login-shell {
    padding: 18px;
  }

  .topbar,
  .status-band,
  .user-block,
  .chat-form {
    align-items: stretch;
    flex-direction: column;
  }

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

  .user-block img {
    display: none;
  }
}
