:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #64717f;
  --line: #d9e2ea;
  --panel: #ffffff;
  --wash: #f5f8fb;
  --blue: #1261a6;
  --cyan: #08859a;
  --red: #b9363c;
  --green: #237a52;
  --gold: #8a6500;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #10202f;
  color: #f4f8fb;
  padding: 22px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 26px;
}

.brand strong {
  font-size: 18px;
  line-height: 1.35;
}

.brand span,
.userbox {
  color: #b7c8d8;
  font-size: 13px;
}

.portal-badge {
  display: grid;
  gap: 4px;
  margin: 14px 0 18px;
  padding: 11px;
  border: 1px solid #31516a;
  border-radius: 8px;
  background: #152c40;
}

.portal-badge span,
.portal-badge small {
  color: #b7c8d8;
  font-size: 12px;
}

.portal-badge b {
  color: #f4f8fb;
  font-size: 14px;
  line-height: 1.35;
}

.sidebar select {
  margin-top: 6px;
  background: #17324a;
  border-color: #31516a;
  color: #f4f8fb;
}

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

.nav button,
.ghost {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 7px;
  color: inherit;
  background: transparent;
}

.nav button.active,
.nav button:hover {
  background: #1d3850;
}

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

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

.topbar h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.25;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.8fr);
  align-items: start;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metrics.compact-metrics {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric b {
  display: block;
  font-size: 26px;
  margin-bottom: 4px;
}

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

.panel,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

.role-brief {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.role-brief span {
  display: block;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.role-brief p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.role-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel h2,
.panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.panel h3 {
  font-size: 15px;
}

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

.form.full {
  grid-template-columns: 1fr;
}

label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #c7d3de;
  border-radius: 6px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
}

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

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

.btn {
  background: var(--blue);
  color: #fff;
  padding: 9px 13px;
  border-radius: 6px;
}

.btn.secondary {
  background: #e9f1f7;
  color: #17324a;
  border: 1px solid #cad8e4;
}

.btn.warn {
  background: var(--red);
}

.btn.good {
  background: var(--green);
}

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

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

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}

th {
  color: #405161;
  background: #f7fafc;
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e9f1f7;
  color: #23465f;
  font-size: 12px;
  white-space: nowrap;
}

.status.finalized,
.status.auto_analyzed,
.status.draft_report,
.status.paid,
.status.converted,
.status.qualified {
  background: #e8f5ee;
  color: var(--green);
}

.status.submitted,
.status.auto_analyzing,
.status.payment_submitted,
.status.new,
.status.contacted {
  background: #fff4d8;
  color: var(--gold);
}

.status.payment_rejected,
.status.closed {
  background: #fff0f0;
  color: var(--red);
}

.analysis {
  display: grid;
  gap: 12px;
}

.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

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

.stack-form {
  display: grid;
  gap: 12px;
}

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

.stack-form textarea {
  resize: vertical;
}

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

.coach-review-panel {
  margin-top: 16px;
}

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

.score {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #fbfdff;
}

.score b {
  display: block;
  font-size: 20px;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  padding: 3px 7px;
  border-radius: 999px;
  background: #e8f3f6;
  color: #075766;
  font-size: 12px;
}

.source-links {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.text-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 700;
}

.text-link:hover {
  text-decoration: underline;
}

.evidence-box {
  border-left: 3px solid var(--gold);
  background: #fffaf0;
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.55;
}

.evidence-box p {
  margin: 4px 0;
}

.research-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

.research-brief p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

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

.research-stats div {
  border-left: 3px solid var(--cyan);
  background: #f7fbfd;
  padding: 8px 10px;
}

.research-stats b {
  display: block;
  font-size: 22px;
}

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

.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
}

.source-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 12px;
}

.source-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.source-head h3 {
  margin: 4px 0 0;
  font-size: 17px;
  line-height: 1.35;
}

.source-kicker {
  color: var(--cyan);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.source-meta {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-section {
  display: grid;
  gap: 6px;
}

.source-section h4 {
  margin: 0;
  font-size: 13px;
  color: #32485a;
}

.source-section p,
.source-section ul {
  margin: 0;
  color: var(--ink);
  line-height: 1.55;
}

.source-section ul {
  padding-left: 18px;
}

.source-warning {
  border-left: 3px solid var(--gold);
  background: #fffaf0;
  padding: 9px 11px;
  color: #5b470d;
  font-size: 13px;
  line-height: 1.55;
}

.micro-model-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 18px;
  align-items: start;
  margin-bottom: 16px;
}

.micro-model-brief h2 {
  margin-top: 6px;
}

.micro-model-brief p {
  margin: 8px 0;
  color: var(--muted);
  line-height: 1.65;
}

.model-loop {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.model-loop div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdff;
  padding: 11px;
}

.model-loop b,
.model-loop span {
  display: block;
}

.model-loop span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-top: 6px;
}

.model-section-grid {
  margin: 16px 0;
}

.model-card-grid {
  display: grid;
  gap: 12px;
}

.model-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 13px;
  display: grid;
  gap: 9px;
}

.model-card h3,
.model-card p {
  margin: 0;
}

.model-card h3 {
  font-size: 15px;
  line-height: 1.35;
}

.model-card p {
  color: var(--muted);
  line-height: 1.55;
}

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

.model-card-row b {
  font-size: 13px;
  color: #32485a;
}

.license-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.report {
  max-height: 620px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.72;
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #10202f 0%, #15506a 100%);
}

.login-box {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 26px;
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.login-box p,
.hint {
  color: var(--muted);
  font-size: 13px;
}

.notice {
  padding: 10px 12px;
  border-radius: 7px;
  background: #eef7fa;
  border: 1px solid #c6e5ee;
  color: #0b5968;
  margin: 12px 0;
}

.payment-panel {
  display: grid;
  justify-items: center;
  text-align: center;
}

.payment-qr-wrap {
  width: min(320px, 100%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  margin: 4px auto 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.payment-qr {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.payment-status {
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.payment-status.pending,
.payment-status.submitted {
  background: #fff4d8;
  color: var(--gold);
}

.payment-status.paid {
  background: #e8f5ee;
  color: var(--green);
}

.payment-status.rejected {
  background: #fff0f0;
  color: var(--red);
}

.payment-summary {
  display: grid;
  gap: 8px;
  margin: 6px 0 12px;
}

.payment-summary div,
.payment-proof-summary div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.payment-proof-summary {
  display: grid;
  gap: 4px;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdff;
}

.payment-summary span,
.payment-proof-summary span {
  color: var(--muted);
  font-size: 13px;
}

.payment-summary b,
.payment-proof-summary b {
  overflow-wrap: anywhere;
}

.table-actions {
  margin-top: 0;
}

.error {
  background: #fff0f0;
  border-color: #f0c7c7;
  color: var(--red);
}

video {
  width: 100%;
  background: #0b1722;
  border-radius: 7px;
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .grid.two,
  .metrics,
  .form,
  .score-grid,
  .payment-summary div,
  .payment-proof-summary div,
  .research-brief,
  .research-stats,
  .micro-model-brief {
    grid-template-columns: 1fr;
  }

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

  .role-brief {
    display: grid;
  }

  .role-actions {
    justify-content: flex-start;
  }
}
