:root {
  --ink: #19202a;
  --muted: #667085;
  --canvas: #f6f8fb;
  --line: #d9e0ea;
  --brand: #246bfe;
  --brand-dark: #174dbd;
  --mint: #21a67a;
  --saffron: #f2a541;
  --rose: #d94f70;
  --white: #ffffff;
  --shadow: 0 12px 40px rgba(25, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(36, 107, 254, 0.08), transparent 270px),
    var(--canvas);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(217, 224, 234, 0.9);
  background: rgba(255, 255, 255, 0.92);
  padding: 12px clamp(16px, 4vw, 40px);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

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

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.nav a {
  border-radius: 6px;
  padding: 9px 12px;
  white-space: nowrap;
}

.nav a:hover,
.nav a.active {
  background: var(--canvas);
  color: var(--ink);
}

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 40px;
}

.hero-strip {
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(36, 107, 254, 0.1), rgba(33, 166, 122, 0.12)),
    var(--white);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

h3 {
  margin-bottom: 6px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
}

.workspace {
  min-width: 0;
}

.sidebar {
  display: grid;
  align-content: start;
  gap: 16px;
  order: 2;
}

.panel,
.card,
.toolbar,
.empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.toolbar {
  margin-bottom: 16px;
  padding: 16px;
}

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

.filters.secondary {
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  margin-top: 10px;
}

.input,
.select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.search-wrap {
  position: relative;
  min-width: 0;
}

.search-wrap span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  border-right: 1px solid var(--line);
  padding-right: 10px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  pointer-events: none;
}

.search-input {
  border-color: rgba(36, 107, 254, 0.38);
  background:
    linear-gradient(180deg, rgba(36, 107, 254, 0.05), rgba(33, 166, 122, 0.04)),
    var(--white);
  padding-left: 82px;
  box-shadow: 0 8px 24px rgba(36, 107, 254, 0.08);
}

.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(36, 107, 254, 0.12);
}

.locked-filter {
  display: flex;
  min-height: 42px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(33, 166, 122, 0.08);
  color: var(--mint);
  padding: 0 12px;
  font-size: 14px;
  font-weight: 800;
}

.input:focus,
.select:focus,
.button:focus-visible,
.nav a:focus-visible,
.link-button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.button.primary {
  background: var(--brand);
  color: var(--white);
}

.button.primary:hover {
  background: var(--brand-dark);
}

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

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

.button.ghost {
  background: transparent;
  color: var(--muted);
}

.button.full {
  width: 100%;
}

.stack {
  display: grid;
  gap: 14px;
}

.small-gap {
  gap: 8px;
}

.card {
  padding: 18px;
}

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

.title-link {
  display: inline-block;
  font-size: 20px;
  font-weight: 850;
}

.title-link:hover {
  color: var(--brand);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.stars {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: #a76512;
  font-weight: 800;
}

.actions {
  display: flex;
  flex-shrink: 0;
  gap: 8px;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--canvas);
  padding: 5px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.badge.safe {
  border-color: rgba(33, 166, 122, 0.35);
  background: rgba(33, 166, 122, 0.1);
  color: var(--mint);
}

.badge.target {
  border-color: rgba(36, 107, 254, 0.35);
  background: rgba(36, 107, 254, 0.1);
  color: var(--brand);
}

.badge.stretch {
  border-color: rgba(242, 165, 65, 0.45);
  background: rgba(242, 165, 65, 0.12);
  color: #a76512;
}

.badge.ambitious {
  border-color: rgba(217, 79, 112, 0.35);
  background: rgba(217, 79, 112, 0.1);
  color: var(--rose);
}

.badge.likely {
  border-color: rgba(33, 166, 122, 0.35);
  background: rgba(33, 166, 122, 0.1);
  color: var(--mint);
}

.badge.possible {
  border-color: rgba(36, 107, 254, 0.35);
  background: rgba(36, 107, 254, 0.1);
  color: var(--brand);
}

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

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--canvas);
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.view-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

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

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

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

.compare-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.compare-table th,
.compare-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px;
  vertical-align: top;
}

.compare-table th:first-child {
  width: 170px;
  background: var(--canvas);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.rank-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 18px;
  align-items: end;
}

.rank-panel h1 {
  font-size: clamp(26px, 3.6vw, 38px);
}

.rank-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
}

.prediction-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.branch-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(36, 107, 254, 0.06);
  padding: 12px;
}

.branch-box span {
  color: var(--muted);
  font-size: 14px;
}

.rating-box {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto minmax(180px, 260px);
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.rating-box p {
  margin-bottom: 0;
  font-size: 13px;
}

.rating-actions {
  display: flex;
  gap: 2px;
}

.star-button {
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: #98a2b3;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.star-button.active,
.star-button:hover,
.star-button:hover ~ .star-button {
  color: var(--saffron);
}

.empty {
  padding: 28px;
  text-align: center;
}

.shortlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--canvas);
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 700;
}

.shortlist-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  cursor: pointer;
  font-weight: 800;
}

.dialog {
  width: min(920px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 22px 70px rgba(25, 32, 42, 0.24);
}

.dialog::backdrop {
  background: rgba(25, 32, 42, 0.42);
}

.dialog-body {
  padding: 22px;
}

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

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 16px;
  margin-top: 16px;
}

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

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

@media (max-width: 1000px) {
  .hero-strip,
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: -1;
  }

  .filters,
  .filters.secondary,
  .form-grid,
  .detail-grid,
  .rank-panel {
    grid-template-columns: 1fr 1fr;
  }

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

  .rating-box {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters,
  .filters.secondary,
  .form-grid,
  .metric-grid,
  .detail-grid,
  .rank-panel {
    grid-template-columns: 1fr;
  }

  .card-header,
  .view-head {
    flex-direction: column;
    align-items: stretch;
  }

  .actions {
    width: 100%;
  }

  .actions .button {
    flex: 1;
  }
}
