:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #66736c;
  --line: #dce4dc;
  --paper: #f5f1e8;
  --panel: #fffdf7;
  --panel-strong: #eef3e8;
  --field: #e2eadb;
  --green: #275d46;
  --green-2: #3f7b5b;
  --gold: #b8872f;
  --red: #b45742;
  --blue: #426a86;
  --shadow: 0 24px 70px rgba(39, 63, 48, 0.14);
  --radius: 22px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(184, 135, 47, 0.16), transparent 34rem),
    linear-gradient(135deg, #f8f3e7 0%, #e6eddc 100%);
  color: var(--ink);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px;
  background: rgba(255, 253, 247, 0.82);
  border-right: 1px solid rgba(39, 93, 70, 0.15);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-lockup { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #fffaf0;
  font-weight: 800;
  letter-spacing: -0.04em;
  border-radius: 16px 16px 6px 16px;
  box-shadow: var(--shadow);
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--green-2);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-weight: 800;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.45rem; letter-spacing: -0.04em; }
h2 { margin-bottom: 16px; font-size: clamp(2.1rem, 4vw, 4.8rem); line-height: 0.92; letter-spacing: -0.07em; max-width: 880px; }
h3 { margin-bottom: 0; font-size: 1.15rem; letter-spacing: -0.03em; }

nav { display: grid; gap: 8px; }
.nav-item {
  color: var(--muted);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 700;
}
.nav-item:hover, .nav-item.active { background: var(--panel-strong); color: var(--green); }

.source-panel, .module, .hero-card, .toolbar, .metrics article, .deal-card {
  background: rgba(255, 253, 247, 0.88);
  border: 1px solid rgba(39, 93, 70, 0.14);
  box-shadow: var(--shadow);
}
.source-panel { margin-top: auto; border-radius: var(--radius); padding: 18px; }
.panel-title { font-weight: 800; margin-bottom: 14px; }
.badge-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  background: #edf4e9;
  color: var(--green);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #5faa73; }
.badge.mock::before { background: var(--gold); }
.badge.live::before { background: #1dbf73; box-shadow: 0 0 0 4px rgba(29,191,115,.16); }
.badge.sourced::before { background: var(--blue); }
.badge.priced::before { background: var(--gold); }
.badge.free::before { background: #7a9e64; }
.badge.missing::before { background: var(--red); }
.microcopy { margin: 14px 0 0; color: var(--muted); font-size: 0.86rem; line-height: 1.45; }

main { padding: 34px; overflow: hidden; }
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 22px;
}
.lede { max-width: 760px; color: var(--muted); font-size: 1.08rem; line-height: 1.55; }
.hero-card { border-radius: 28px; padding: 24px; align-self: end; position: relative; overflow: hidden; }
.hero-card::after { content: ""; position: absolute; inset: auto -60px -70px auto; width: 160px; height: 160px; background: rgba(39, 93, 70, 0.12); border-radius: 50%; }
.hero-card p { margin: 0 0 14px; color: var(--muted); font-weight: 700; }
.hero-card strong { display: block; font-size: 4rem; line-height: 1; letter-spacing: -0.08em; }
.hero-card span:last-child { color: var(--muted); }
.status-dot { width: 11px; height: 11px; border-radius: 50%; background: #61bf7b; display: inline-block; box-shadow: 0 0 0 8px rgba(97,191,123,.16); margin-bottom: 18px; }

.toolbar { border-radius: var(--radius); padding: 16px; display: grid; grid-template-columns: 1fr 260px auto; gap: 12px; margin-bottom: 18px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; }
input, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  background: #fffefb;
  color: var(--ink);
  outline: none;
}
input:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 4px rgba(63, 123, 91, 0.14); }
.primary, #rerunButton {
  border: 0;
  border-radius: 14px;
  min-height: 46px;
  padding: 0 18px;
  background: var(--green);
  color: #fffdf7;
  font-weight: 900;
}
.ghost {
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--green);
  padding: 8px 12px;
  border-radius: 12px;
  font-weight: 800;
}
.full { width: 100%; margin-top: 18px; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.metrics article { border-radius: 18px; padding: 16px; }
.metrics span { display: block; color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.metrics strong { display: block; margin-top: 8px; font-size: 1.7rem; letter-spacing: -0.05em; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head > span { color: var(--muted); font-weight: 800; font-size: 0.86rem; }
.compact { margin-bottom: 16px; }
.card-stack { display: grid; gap: 14px; }
.deal-card { border-radius: 24px; padding: 18px; display: grid; grid-template-columns: 94px 1fr; gap: 18px; transition: transform .18s ease, border-color .18s ease; }
.deal-card:hover { transform: translateY(-2px); }
.deal-card.selected { border-color: rgba(39, 93, 70, 0.65); outline: 4px solid rgba(39, 93, 70, 0.09); }
.score-tile {
  border-radius: 20px;
  background: linear-gradient(150deg, var(--green), #17362a);
  color: white;
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 110px;
}
.score-tile strong { font-size: 2.2rem; letter-spacing: -0.07em; }
.score-tile span { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; opacity: .8; }
.deal-body { min-width: 0; }
.deal-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.deal-top button { border: 0; background: transparent; color: var(--green); font-weight: 900; padding: 2px 0; }
.address { margin: 5px 0 10px; color: var(--muted); }
.live-line { margin: 10px 0; padding: 10px 12px; background: rgba(39,93,70,.08); border: 1px solid rgba(39,93,70,.14); border-radius: 14px; color: var(--green); font-weight: 800; }
.source-line { margin: 10px 0; color: #47554d; font-size: .92rem; line-height: 1.45; }
.source-line a { color: var(--green); font-weight: 900; }
.tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.tag { padding: 6px 9px; border-radius: 999px; background: var(--field); color: #405046; font-size: .78rem; font-weight: 800; }
.card-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.card-grid div { padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.45); }
.card-grid span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; }
.card-grid strong { display: block; margin-top: 4px; font-size: .96rem; }

.right-rail { display: grid; gap: 18px; position: sticky; top: 24px; }
.module { border-radius: var(--radius); padding: 18px; }
.criteria-list { display: grid; gap: 16px; }
.criterion { display: grid; gap: 8px; }
.criterion-head { display: flex; justify-content: space-between; color: var(--muted); font-size: .84rem; font-weight: 900; }
input[type="range"] { accent-color: var(--green); min-height: auto; padding: 0; }
.toggle-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.toggle {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffefb;
  color: var(--muted);
  padding: 8px 11px;
  font-size: .8rem;
  font-weight: 900;
}
.toggle.active { background: var(--green); color: white; border-color: var(--green); }
.explain-card { text-align: left; }
.score-ring {
  width: 136px;
  height: 136px;
  border-radius: 50%;
  margin: 18px auto;
  display: grid;
  place-items: center;
  color: var(--green);
  font-size: 2.4rem;
  font-weight: 900;
  background: conic-gradient(var(--green) 0deg, var(--green) var(--scoreDeg, 0deg), #dfe8dc var(--scoreDeg, 0deg));
  position: relative;
}
.score-ring::before { content: ""; position: absolute; inset: 12px; border-radius: 50%; background: var(--panel); }
.score-ring { isolation: isolate; }
.score-ring::after { content: attr(data-label); position: relative; z-index: 1; }
.explain-list { padding: 0; margin: 0; display: grid; gap: 10px; list-style: none; }
.explain-list li { display: grid; grid-template-columns: 1fr auto; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 9px; color: var(--muted); }
.explain-list strong { color: var(--ink); }

.knowledge-gap ul { margin: 8px 0 12px; padding-left: 18px; color: var(--muted); }
.knowledge-gap li { margin: 8px 0; }
.knowledge-gap p { margin-bottom: 0; color: var(--green); }
.cost-map { margin-top: 20px; overflow-x: auto; }
.cost-map table { width: 100%; border-collapse: collapse; min-width: 760px; }
.cost-map th, .cost-map td { text-align: left; vertical-align: top; padding: 12px; border-bottom: 1px solid var(--line); }
.cost-map th { color: var(--green); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.cost-map td:nth-child(2) { font-weight: 900; color: var(--ink); white-space: nowrap; }
.run-log { margin-top: 20px; }
.run-log ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.run-log li { display: grid; grid-template-columns: 88px 1fr auto; gap: 12px; align-items: center; padding: 13px; background: rgba(238, 243, 232, 0.7); border-radius: 16px; }
.run-log time { color: var(--green); font-weight: 900; }
.run-log p { margin: 0; color: var(--muted); }
.run-log b { color: var(--ink); }
.run-log .pill { background: #fffdf7; border: 1px solid var(--line); padding: 5px 9px; border-radius: 999px; font-size: .76rem; font-weight: 900; color: var(--muted); }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  background: #17201c;
  color: white;
  padding: 14px 16px;
  border-radius: 16px;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  opacity: 0;
  transition: .22s ease;
  font-weight: 800;
}
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .source-panel { margin-top: 0; flex: 1 1 420px; }
  nav { grid-auto-flow: column; overflow-x: auto; }
  .workspace, .hero { grid-template-columns: 1fr; }
  .right-rail { position: static; }
}
@media (max-width: 760px) {
  main, .sidebar { padding: 18px; }
  .toolbar, .metrics, .card-grid { grid-template-columns: 1fr; }
  .deal-card { grid-template-columns: 1fr; }
  .score-tile { min-height: 88px; }
  .run-log li { grid-template-columns: 1fr; }
}
