:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #64706a;
  --line: #dce3dc;
  --soft: #f3f6f1;
  --paper: #fbfcf7;
  --panel: rgba(255, 255, 255, 0.84);
  --green: #2b7a4b;
  --blue: #2366a8;
  --gold: #b8791a;
  --red: #b9483d;
  --shadow: 0 18px 50px rgba(32, 46, 40, 0.12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf4ef;
  --muted: #a7b5ad;
  --line: #31423a;
  --soft: #17231e;
  --paper: #0e1512;
  --panel: rgba(22, 31, 27, 0.9);
  --green: #62c58b;
  --blue: #6da8ea;
  --gold: #e0ad55;
  --red: #ee7d73;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(43, 122, 75, 0.08), transparent 30%),
    linear-gradient(315deg, rgba(35, 102, 168, 0.08), transparent 32%),
    var(--paper);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  padding: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--green), var(--blue));
  border-radius: 8px;
  font-weight: 900;
  font-size: 22px;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 18px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

.login-panel h1 {
  margin: 14px 0 8px;
  font-size: clamp(34px, 8vw, 48px);
  line-height: 1.02;
}

.login-copy,
.pick-card p,
.source-card p,
.intro p,
.workflow span,
.brief-list p,
.record-list p,
.chart-card p {
  color: var(--muted);
  line-height: 1.68;
}

.login-form {
  margin-top: 28px;
}

.login-form label {
  display: block;
  margin-bottom: 10px;
  font-weight: 800;
}

.pass-row {
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 10px;
}

.pass-row input,
.add-form input,
.add-form select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
  color: var(--ink);
  background: var(--panel);
}

.pass-row button,
.ghost-button,
.primary-button,
.segmented button,
.range-row button {
  min-height: 40px;
  border-radius: 8px;
  font-weight: 800;
}

.pass-row button,
.primary-button {
  border: 0;
  color: white;
  background: var(--ink);
}

.error-text {
  min-height: 22px;
  margin: 10px 0 0;
  color: var(--red);
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: color-mix(in srgb, var(--panel), transparent 8%);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

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

.brand-row strong,
.brand-row span {
  display: block;
}

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

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

nav button {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
}

nav button.active,
nav button:hover {
  color: var(--ink);
  background: var(--soft);
  border-color: var(--line);
}

.domain-card {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.domain-card span,
.domain-card strong {
  display: block;
}

.domain-card span {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

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

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

.topbar h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
}

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

.ghost-button {
  padding: 0 14px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
}

.hero-band,
.panel,
.pick-card,
.source-card,
.metric-card,
.chart-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 28px rgba(32, 46, 40, 0.07);
}

.hero-band {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 34%);
  gap: 24px;
  align-items: center;
  min-height: 220px;
  padding: 28px;
  margin-bottom: 18px;
  overflow: hidden;
}

.hero-band h2 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.04;
}

.market-board {
  display: grid;
  gap: 12px;
}

.market-board div,
.thresholds div,
.fix-list span,
.run-meta span {
  padding: 14px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.market-board span,
.market-board b,
.metric-card span,
.metric-card strong {
  display: block;
}

.market-board span,
.thresholds span,
.metric-card span,
.candidate-row div span,
.candidate-row > span,
.chart-card .card-head span {
  color: var(--muted);
}

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

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

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

.pick-card,
.source-card,
.panel,
.metric-card,
.chart-card {
  padding: 22px;
}

.pick-card {
  min-height: 420px;
}

.pick-card.empty {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.card-head,
.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pick-card h2 {
  margin-bottom: 4px;
  font-size: 30px;
}

.pick-card h3 {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.strong { color: #0d5b36; background: #dff4e8; }
.badge.watch { color: #7a4d09; background: #f7ead1; }
.badge.neutral { color: #194f82; background: #dcecff; }
.badge.muted { color: #696969; background: #eeeeee; }

.score-line {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0;
  color: var(--muted);
}

.score-ring {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--green) var(--score), color-mix(in srgb, var(--line), transparent 20%) 0deg);
}

.score-ring span {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border-radius: 50%;
  font-weight: 900;
  font-size: 22px;
}

.evidence-list,
.framework-card ul {
  margin: 0 0 16px;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.7;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  padding: 0 16px;
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
  margin: 18px 0;
}

.panel.accent {
  background: color-mix(in srgb, var(--green), var(--panel) 90%);
}

.fix-list,
.brief-list,
.record-list {
  display: grid;
  gap: 12px;
}

.audit-grid,
.chart-grid,
.weights-grid,
.framework-grid {
  display: grid;
  gap: 12px;
}

.audit-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 16px;
}

.audit-card,
.weight-card {
  padding: 16px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.audit-card div {
  display: flex;
  justify-content: space-between;
  margin: 10px 0;
  color: var(--muted);
}

.audit-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.run-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

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

.add-form label {
  display: grid;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-weight: 800;
}

.add-form .primary-button {
  grid-column: 1 / -1;
  margin-top: 0;
}

.segmented,
.range-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented button,
.range-row button {
  padding: 0 12px;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
}

.segmented button.active,
.range-row button.active {
  color: white;
  background: var(--green);
  border-color: var(--green);
}

.range-row {
  margin: 16px 0;
}

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

.chart-card .card-head strong,
.chart-card .card-head span {
  display: block;
}

.trend-chart {
  width: 100%;
  height: auto;
  margin: 16px 0 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.trend-chart path {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}

.trend-old {
  stroke: #9ca3a3;
}

.trend-new {
  stroke: var(--green);
}

.trend-chart line {
  stroke: var(--gold);
  stroke-dasharray: 4 5;
}

.trend-chart text {
  fill: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  margin: 10px 0;
  font-size: 32px;
}

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

.weight-card {
  min-height: 112px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.weight-card strong,
.weight-card span {
  display: block;
}

.weight-card span {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.weight-card b {
  color: var(--green);
  font-size: 28px;
}

.red-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.red-flags span {
  padding: 10px 12px;
  color: #7a251f;
  background: #fae8e6;
  border-radius: 8px;
  border: 1px solid #f0c9c5;
}

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

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .domain-card {
    position: static;
    margin-top: 18px;
  }

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

  nav button {
    text-align: center;
  }

  .hero-band,
  .split,
  .grid.three,
  .grid.two,
  .weights-grid,
  .framework-grid,
  .chart-grid,
  .audit-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main,
  .sidebar,
  .login-panel {
    padding: 18px;
  }

  .topbar,
  .card-head,
  .table-head {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .pass-row,
  .add-form {
    grid-template-columns: 1fr;
  }

  .pass-row button {
    min-height: 44px;
  }

  .hero-band h2 {
    font-size: 32px;
  }
}
