:root {
  color-scheme: light;
  --bg: #f7f8f3;
  --ink: #17201c;
  --muted: #65706a;
  --line: #dfe5dc;
  --panel: #ffffff;
  --soft: #eef3ea;
  --accent: #0b6b56;
  --accent-strong: #084f42;
  --gold: #c27a16;
  --blue: #225f9e;
  --danger: #a13e32;
  --shadow: 0 18px 50px rgba(27, 38, 33, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(11, 107, 86, 0.08), transparent 34%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  min-height: 100vh;
}

.sidebar {
  background: rgba(255, 255, 255, 0.78);
  padding: 16px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  letter-spacing: 0;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.section-heading h2,
.section-heading p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.2;
}

.brand p,
.section-heading p,
.eyebrow {
  color: var(--muted);
}

.nav-list {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav-item {
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  flex: 0 0 auto;
  padding: 10px 12px;
  text-align: center;
  white-space: nowrap;
}

.nav-item.active {
  background: var(--soft);
  color: var(--ink);
}

.side-panel {
  border-top: 1px solid var(--line);
  padding: 14px 0 0;
}

.side-panel h2 {
  font-size: 13px;
  margin: 0 0 14px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  margin-right: 10px;
  color: #35413b;
}

.check-row input {
  accent-color: var(--accent);
}

.metric {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  color: var(--muted);
}

.metric strong {
  color: var(--ink);
  text-align: right;
}

.workspace {
  padding: 16px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.eyebrow {
  font-size: 13px;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar h2 {
  font-size: 30px;
  line-height: 1.08;
  max-width: 760px;
}

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

.primary-button,
.secondary-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
  min-height: 42px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--accent);
  color: white;
  padding: 0 16px;
  font-weight: 750;
  justify-content: center;
  flex: 1;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.secondary-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  font-weight: 800;
  padding: 0 14px;
}

.secondary-button:hover {
  border-color: var(--accent);
}

.icon-button {
  width: 42px;
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}

.control-surface,
.summary-grid,
.insight-grid,
.results-section,
.debug-section {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.control-surface {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.control-surface.collapsed {
  display: none;
}

.field-group {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-group label {
  color: var(--muted);
  font-size: 13px;
}

.field-group input,
.field-group select {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  margin-bottom: 16px;
}

.insight-grid {
  display: grid;
  gap: 1px;
  overflow: hidden;
  margin-bottom: 16px;
}

.insight-panel {
  background: rgba(255, 255, 255, 0.7);
  padding: 14px;
}

.insight-panel div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.insight-panel strong {
  text-align: right;
}

.insight-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 8px 0 0;
}

.summary-item {
  padding: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-item:nth-child(2n) {
  border-right: 0;
}

.summary-item:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.summary-item strong {
  font-size: 25px;
}

.results-section {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: stretch;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading h2 {
  font-size: 22px;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 6px;
}

.dot.buy {
  background: var(--accent);
}

.dot.watch {
  background: var(--gold);
}

.dot.skip {
  background: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
}

th,
td {
  padding: 0;
  text-align: left;
  vertical-align: middle;
}

thead {
  display: none;
}

td {
  font-size: 14px;
}

.result-card-cell {
  border: 0;
}

.result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  padding: 12px 14px;
  text-align: left;
}

.result-card:hover,
.result-card.expanded {
  border-color: rgba(11, 107, 86, 0.45);
  background: #fbfdfb;
}

.domain-cell strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.domain-cell span,
.signal-list {
  color: var(--muted);
  font-size: 12px;
}

.score-pill,
.action-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  height: 30px;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
}

.score-pill {
  background: #e7f4ee;
  color: var(--accent-strong);
}

.action-pill.buy {
  background: #e7f4ee;
  color: var(--accent-strong);
}

.action-pill.watch {
  background: #fff2dc;
  color: #8a520f;
}

.action-pill.skip {
  background: #fbe9e7;
  color: var(--danger);
}

.watch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  margin-left: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
}

.watch-button:hover {
  border-color: var(--accent);
}

.load-more-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 850;
}

.load-more-button:hover {
  background: var(--accent-strong);
}

.load-more-button[hidden] {
  display: none;
}

.debug-section {
  margin-top: 16px;
  padding: 14px;
}

.debug-section summary {
  cursor: pointer;
  font-weight: 800;
}

.debug-grid {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.debug-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 11px;
}

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

.debug-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.signal-list {
  max-width: 320px;
  line-height: 1.45;
}

.result-details {
  display: none;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  background: #fff;
  margin-top: -7px;
  padding: 14px;
}

.result-details.open {
  display: block;
}

.result-details dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.result-details div {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.result-details div:last-child {
  border-bottom: 0;
}

.result-details dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.result-details dd {
  margin: 0;
  max-width: 65%;
  text-align: right;
  line-height: 1.35;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

@media (max-width: 720px) {
  .table-wrap {
    overflow: visible;
  }

  table {
    min-width: 0;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    display: block;
  }

  td {
    display: block;
  }

  td::before {
    content: none;
  }

  td:first-child {
    display: block;
    text-align: left;
    padding-top: 0;
  }

  td:first-child::before {
    display: none;
  }

  td:last-child {
    padding-bottom: 0;
  }

  td:last-child {
    align-items: center;
  }

  .watch-button {
    margin-left: 6px;
  }

  .result-details dd {
    max-width: 62%;
  }

  .result-card {
    background: white;
    box-shadow: none;
  }

  .result-card .score-pill {
    min-width: 64px;
  }

  .signal-list {
    max-width: none;
  }
}

@media (min-width: 720px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    justify-content: space-between;
  }

  .primary-button {
    flex: 0 0 auto;
  }

  .secondary-button {
    flex: 0 0 auto;
  }

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

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

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

  .result-details dl {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 18px;
  }

  .section-heading {
    align-items: end;
    flex-direction: row;
    justify-content: space-between;
  }
}

@media (min-width: 980px) {
  .app-shell {
    grid-template-columns: 280px minmax(0, 1fr);
  }

  .sidebar {
    border-right: 1px solid var(--line);
    padding: 28px 22px;
  }

  .brand {
    gap: 14px;
    margin-bottom: 34px;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .nav-list {
    display: grid;
    gap: 8px;
    margin-bottom: 28px;
    overflow: visible;
    padding-bottom: 0;
  }

  .nav-item {
    text-align: left;
  }

  .nav-item:hover {
    background: var(--soft);
    color: var(--ink);
  }

  .side-panel {
    padding: 22px 0;
  }

  .check-row {
    display: flex;
    margin-right: 0;
    min-height: 34px;
  }

  .workspace {
    padding: 28px;
  }

  .topbar h2 {
    font-size: clamp(34px, 3vw, 42px);
  }

  .control-surface {
    grid-template-columns: 1.1fr 2fr 0.75fr 0.75fr 1.2fr;
  }

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

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

  .summary-item {
    padding: 17px 18px;
    border-bottom: 0;
  }

  .summary-item:nth-child(2n) {
    border-right: 1px solid var(--line);
  }

  .summary-item:last-child {
    border-right: 0;
  }
}

@media (max-width: 680px) {
  .brand p {
    display: none;
  }

  .topbar h2 {
    font-size: 28px;
  }

  .side-panel h2 {
    margin-bottom: 8px;
  }
}
