:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --sidebar-bg: #fbfcfd;
  --table-head-bg: #f0f5f8;
  --table-text: #26364a;
  --row-hover: #f8fbfc;
  --row-expanded: #fbfdfc;
  --detail-bg: #ffffff;
  --ink: #162235;
  --muted: #607086;
  --line: #dce4ec;
  --line-strong: #bdccd8;
  --teal: #0f766e;
  --teal-dark: #0b514d;
  --gold: #b78a2f;
  --blue: #315a89;
  --green: #27835c;
  --red: #a54242;
  --pill-gold-line: rgba(183, 138, 47, 0.26);
  --pill-gold-bg: rgba(183, 138, 47, 0.1);
  --pill-gold-ink: #75591b;
  --shadow: 0 18px 42px rgba(31, 45, 61, 0.08);
  --radius: 8px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101416;
  --surface: #181d1f;
  --surface-2: #202729;
  --sidebar-bg: #14191b;
  --table-head-bg: #1d2527;
  --table-text: #d6dee2;
  --row-hover: #1d2426;
  --row-expanded: #1b2421;
  --detail-bg: #151b1d;
  --ink: #eef4f1;
  --muted: #a8b4b9;
  --line: #2b3639;
  --line-strong: #3c4a4e;
  --teal: #46c0ad;
  --teal-dark: #8ce3d4;
  --gold: #d8b461;
  --blue: #9abfe0;
  --green: #67c18d;
  --red: #d77979;
  --pill-gold-line: rgba(216, 180, 97, 0.36);
  --pill-gold-bg: rgba(216, 180, 97, 0.14);
  --pill-gold-ink: #f1dba0;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--teal);
  font-weight: 750;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  border-right: 1px solid var(--line);
  background: var(--sidebar-bg);
  padding: 22px 16px;
}

.brand {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 0 8px 22px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.brand-mark img,
.topbar-mark img {
  display: block;
  max-width: 100%;
  height: auto;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
  text-align: left;
  font-size: 0.9rem;
  font-weight: 780;
}

.nav-button::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
}

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

.nav-button.active::after {
  background: var(--teal);
}

.sidebar-note {
  margin: 26px 8px 0;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  color: var(--muted);
  font-size: 0.78rem;
}

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

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: start;
  margin-bottom: 20px;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.title-group h1 {
  margin: 0 0 4px;
  font-size: 1.8rem;
  font-weight: 860;
  letter-spacing: 0;
  line-height: 1.12;
}

.title-group p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.pill.teal {
  border-color: rgba(15, 118, 110, 0.24);
  background: rgba(15, 118, 110, 0.08);
  color: var(--teal-dark);
}

.pill.gold {
  border-color: var(--pill-gold-line);
  background: var(--pill-gold-bg);
  color: var(--pill-gold-ink);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: rgba(15, 118, 110, 0.42);
  background: rgba(15, 118, 110, 0.08);
  outline: none;
}

.theme-toggle-icon {
  position: relative;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.theme-toggle-icon::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background:
    linear-gradient(currentColor, currentColor) center top / 2px 3px no-repeat,
    linear-gradient(currentColor, currentColor) center bottom / 2px 3px no-repeat,
    linear-gradient(currentColor, currentColor) left center / 3px 2px no-repeat,
    linear-gradient(currentColor, currentColor) right center / 3px 2px no-repeat;
  opacity: 0.82;
}

html[data-theme="dark"] .theme-toggle-icon {
  overflow: hidden;
  border-color: currentColor;
}

html[data-theme="dark"] .theme-toggle-icon::after {
  inset: -2px -5px 2px 5px;
  background: var(--surface);
  opacity: 1;
}

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

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel.pad {
  padding: 16px;
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.metric {
  display: grid;
  gap: 3px;
  min-height: 94px;
  align-content: center;
}

.metric strong {
  color: var(--ink);
  font-size: 1.9rem;
  font-weight: 880;
  line-height: 1;
}

.metric span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 740;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.2;
}

.panel-title small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
}

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

.definition-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.definition-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.definition-row dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.definition-row dd {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--blue);
  padding: 0 9px;
  font-size: 0.76rem;
  font-weight: 780;
}

.rule-list,
.source-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rule-list li,
.source-list li {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  color: var(--ink);
  font-size: 0.9rem;
}

.rule-list li:first-child,
.source-list li:first-child {
  border-top: 0;
  padding-top: 0;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) minmax(160px, 220px) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.toolbar.compact {
  grid-template-columns: minmax(220px, 1fr) minmax(150px, 210px) auto;
}

.toolbar.comparable-toolbar {
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 240px) minmax(130px, 170px) minmax(130px, 170px) auto;
}

.toolbar.prospect-toolbar {
  grid-template-columns: minmax(220px, 1fr) repeat(5, minmax(130px, 170px)) auto;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 830;
}

input,
select {
  min-width: 0;
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 10px;
}

.button {
  min-height: 38px;
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  background: var(--teal);
  color: #ffffff;
  padding: 0 12px;
  font-size: 0.86rem;
  font-weight: 850;
  white-space: nowrap;
}

.button.secondary {
  border-color: var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.54;
}

.export-status {
  min-height: 20px;
  margin: -4px 0 12px;
  color: var(--teal-dark);
  font-size: 0.78rem;
  font-weight: 760;
}

.export-card .export-status {
  margin: 0;
}

.table-panel {
  overflow: hidden;
}

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

table {
  width: 100%;
  min-width: 1200px;
  border-collapse: collapse;
  table-layout: fixed;
}

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

th {
  background: var(--table-head-bg);
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 860;
}

td {
  color: var(--table-text);
}

tbody tr:hover {
  background: var(--row-hover);
}

tbody tr.prospect-row-expanded {
  background: var(--row-expanded);
}

tbody tr.prospect-detail-row td {
  padding: 0 10px 14px;
  background: var(--row-expanded);
}

.checkbox-cell {
  width: 42px;
  text-align: center;
}

.details-cell {
  width: 84px;
}

.score-cell {
  width: 92px;
}

.score-badge {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 850;
}

.score-badge.high {
  background: rgba(15, 118, 110, 0.12);
  color: var(--teal-dark);
}

.score-badge.mid {
  background: rgba(183, 138, 47, 0.14);
  color: var(--pill-gold-ink);
}

.score-badge.low {
  background: rgba(96, 112, 134, 0.12);
  color: var(--muted);
}

.cell-muted {
  color: var(--muted);
}

.cell-clamp {
  display: -webkit-box;
  max-height: 4.3em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.cell-clamp.expanded {
  display: block;
  max-height: none;
  overflow: visible;
  -webkit-line-clamp: unset;
  line-clamp: unset;
}

.row-toggle {
  min-height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--teal-dark);
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.row-toggle:hover,
.row-toggle:focus-visible {
  border-color: rgba(15, 118, 110, 0.38);
  background: rgba(15, 118, 110, 0.08);
  outline: none;
}

.prospect-detail {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: min(1040px, calc(100vw - 340px));
  max-width: 100%;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: var(--radius);
  background: var(--detail-bg);
  padding: 12px;
}

.prospect-detail-block {
  min-width: 0;
}

.prospect-detail-block h3 {
  margin: 0 0 5px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 860;
  letter-spacing: 0;
  text-transform: uppercase;
}

.prospect-detail-block p {
  margin: 0;
  color: var(--table-text);
  font-size: 0.86rem;
  line-height: 1.48;
}

.empty-state {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 38px 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 1rem;
}

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

.export-card {
  display: grid;
  gap: 12px;
  align-content: start;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
}

.export-card h2 {
  margin: 0;
  font-size: 1rem;
}

.export-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

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

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

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

  .sidebar-note {
    display: none;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 12;
  }

  .prospect-detail {
    width: calc(100vw - 72px);
  }
}

@media (max-width: 760px) {
  .main {
    padding: 18px 14px 36px;
  }

  .topbar,
  .toolbar,
  .toolbar.comparable-toolbar,
  .toolbar.compact,
  .export-grid {
    grid-template-columns: 1fr;
  }

  .status-stack {
    justify-content: flex-start;
  }

  .topbar-mark {
    width: 42px;
    height: 42px;
  }

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

  .definition-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .prospect-detail {
    grid-template-columns: 1fr;
    width: calc(100vw - 48px);
  }
}
