:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #101828;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #d9e2ef;
  --line-soft: #e8eef7;
  --primary: #3454d1;
  --primary-soft: #eef2ff;
  --primary-border: #a99cff;
  --green: #14a35b;
  --green-soft: #dcfce7;
  --red: #e5484d;
  --red-soft: #fee2e2;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 48px rgba(16, 24, 40, 0.08);
  --font: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  width: 100%;
  overflow-x: hidden;
  background: radial-gradient(circle at top left, #eef0ff 0, #f8fafc 360px, #f5f7fb 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden,
.hidden-select {
  display: none !important;
}

/* Header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  padding: 18px clamp(18px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
}

.brand-logo {
  display: inline-grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1e48d8, #4a44d9);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(52, 84, 209, 0.22);
}

.brand strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
}

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

.topnav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 18px;
  border-radius: 999px;
  color: #344054;
  font-weight: 700;
  text-decoration: none;
}

.topnav a.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Page */

.page {
  width: min(100% - 32px, 1440px);
  margin: 0 auto;
  padding: 18px 0 42px;
}

.screen-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.hero {
  padding: 42px 54px 32px;
  border-bottom: 1px solid var(--line-soft);
}

.hero h1 {
  margin: 0;
  max-width: 760px;
  font-size: 30px;
  line-height: 1.16;
  letter-spacing: -0.04em;
  font-weight: 760;
}

.hero p {
  margin: 14px 0 0;
  max-width: 920px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 500;
}

/* Selector blocks */

.selector-block {
  padding: 28px 54px;
  border-bottom: 1px solid var(--line-soft);
}

.selector-block.compact {
  padding-top: 24px;
  padding-bottom: 24px;
}

.step-head {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  margin-bottom: 18px;
}

.step-num,
.step-number {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.step-head h2,
.selector-block h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 740;
}

.step-head p,
.selector-block p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 600;
}

/* Market and segment cards */

.market-row,
.segment-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  width: 100%;
}

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

.market-card,
.segment-card {
  appearance: none;
  display: block;
  width: 100%;
  min-height: 104px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--text);
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.segment-card {
  min-height: 82px;
}

.market-card:hover,
.segment-card:hover,
.market-card.active,
.segment-card.active {
  border-color: var(--primary-border);
  background: linear-gradient(180deg, #ffffff 0%, #faf9ff 100%);
  box-shadow: 0 10px 28px rgba(52, 84, 209, 0.08);
}

.market-card strong,
.segment-card strong {
  display: block;
  margin-bottom: 12px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
  font-weight: 720;
}

.segment-card strong {
  margin-bottom: 10px;
  font-size: 16px;
}

.market-meta,
.segment-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.market-card span,
.segment-card span,
.empty-facts span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475467;
  font-size: 13px;
  line-height: 1;
  font-weight: 700;
}

.badge.good,
.market-card span.good,
.segment-card span.good {
  background: var(--green-soft);
  color: #087443;
}

.badge.warn {
  background: #fff7d6;
  color: #946200;
}

/* Current context */

.analysis-area {
  display: block;
}

.analysis-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 24px;
  align-items: center;
  padding: 28px 54px;
  border-bottom: 1px solid var(--line-soft);
}

.analysis-head h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 740;
}

.analysis-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.toolbar {
  width: 100%;
}

.toolbar input,
#capabilitySearch {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--text);
  outline: none;
}

.toolbar input:focus,
#capabilitySearch:focus {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 4px rgba(52, 84, 209, 0.08);
}

/* Groups */

.group-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.group-chip,
#groupChips button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}

.group-chip.active,
#groupChips button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.group-chip span,
#groupChips button span {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: #2f35a5;
  font-weight: 800;
}

.group-chip.active span,
#groupChips button.active span {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* Apps */

.apps-panel {
  padding: 26px 54px;
  border-bottom: 1px solid var(--line-soft);
}

.apps-panel .panel-head,
.apps-panel > div:first-child {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.apps-panel h2,
.apps-panel h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 740;
}

.apps-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.apps-row,
.apps-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.app-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  color: var(--text);
  font-weight: 760;
}

.app-card img,
.app-placeholder {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  object-fit: cover;
}

.app-placeholder {
  display: inline-grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
}

.app-card span:last-child,
.app-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Matrix and analytics */

.matrix-card {
  padding: 0;
  border-bottom: 0;
}

.matrix-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 54px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.matrix-head h2,
.matrix-head h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 740;
}

.matrix-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 14px;
  color: var(--muted);
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
}

.dot.confirmed {
  background: var(--green);
}

.dot.detected {
  background: #2f6fed;
}

.dot.suspected {
  background: #d97706;
}

.dot.empty {
  background: #cbd5e1;
}

.matrix-wrap {
  width: 100%;
  overflow: visible;
}

.compact-analytics {
  padding: 26px 54px 34px;
}

.compact-analytics__head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.compact-analytics__head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 740;
}

.compact-analytics__head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.compact-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.compact-summary-table,
.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
}

.compact-summary-table th,
.compact-summary-table td,
.matrix-table th,
.matrix-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--text);
  text-align: left;
  vertical-align: middle;
}

.compact-summary-table th,
.matrix-table th {
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
  font-weight: 760;
}

.compact-summary-table tr:last-child td,
.matrix-table tr:last-child td {
  border-bottom: 0;
}

.compact-app {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-weight: 760;
}

.compact-app img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
}

.compact-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475467;
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
}

.compact-status.ok {
  background: var(--green-soft);
  color: #087443;
}

.compact-status.muted {
  background: #f1f5f9;
  color: #667085;
}

.compact-note {
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.matrix-details {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
}

.matrix-details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  color: var(--text);
  font-size: 16px;
  font-weight: 760;
  cursor: pointer;
  list-style: none;
}

.matrix-details > summary::-webkit-details-marker {
  display: none;
}

.matrix-details > summary small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.matrix-scroll {
  overflow-x: auto;
  border-top: 1px solid var(--line-soft);
}

.matrix-table {
  min-width: 720px;
}

.matrix-table th:not(:first-child),
.matrix-table td:not(:first-child) {
  text-align: center;
}

.matrix-table th:first-child,
.matrix-table td:first-child {
  width: 34%;
  min-width: 260px;
}

.cap-title {
  font-weight: 760;
}

.cap-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.status-pill {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #8ca0b8;
  font-weight: 900;
}

.status-pill.confirmed,
.status-pill.detected {
  background: var(--green-soft);
  color: #087443;
}

.status-pill.partial,
.status-pill.suspected {
  background: #fff7d6;
  color: #946200;
}

.status-pill.rejected {
  background: var(--red-soft);
  color: var(--red);
}

.status-pill.not_mapped,
.status-pill.unknown {
  background: #f1f5f9;
  color: #8ca0b8;
}

/* Empty / loading / error */

.skeleton,
.empty-state,
.error {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
}

.empty-state {
  margin: 26px 54px;
  text-align: center;
}

.empty-state h3 {
  margin: 8px 0;
  color: var(--text);
  font-size: 20px;
}

.empty-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.error {
  margin: 32px 54px;
  border-color: #fecaca;
  background: #fee2e2;
  color: #dc2626;
}

/* Desktop adaptive */

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

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

/* Tablet */

@media (max-width: 860px) {
  .page {
    width: min(100% - 20px, 760px);
    padding: 12px 0 28px;
  }

  .topbar {
    padding: 14px 16px;
  }

  .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand small {
    font-size: 12px;
  }

  .topnav a {
    min-height: 34px;
    padding: 0 12px;
    font-size: 13px;
  }

  .hero,
  .selector-block,
  .analysis-head,
  .apps-panel,
  .matrix-head,
  .compact-analytics {
    padding-left: 28px;
    padding-right: 28px;
  }

  .hero h1 {
    font-size: 26px;
  }

  .hero p {
    font-size: 15px;
  }

  .analysis-head {
    grid-template-columns: 1fr;
  }

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

/* Mobile: separate usable flow, no squeezed desktop */

@media (max-width: 640px) {
  body {
    font-size: 14px;
    background: #f5f7fb;
  }

  .topbar {
    position: static;
    display: block;
    padding: 14px 14px 10px;
  }

  .brand {
    width: 100%;
    justify-content: flex-start;
  }

  .brand-logo {
    width: 42px;
    height: 42px;
  }

  .brand strong {
    font-size: 18px;
  }

  .brand small {
    max-width: 210px;
    font-size: 12px;
    line-height: 1.25;
  }

  .topnav {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-top: 12px;
  }

  .topnav a {
    min-height: 34px;
    padding: 0 8px;
    font-size: 13px;
  }

  .page {
    width: 100%;
    padding: 0 8px 28px;
  }

  .screen-card {
    border-radius: 20px;
  }

  .hero {
    padding: 24px 18px 22px;
  }

  .hero h1 {
    max-width: 100%;
    font-size: 24px;
    line-height: 1.18;
    letter-spacing: -0.03em;
  }

  .hero p {
    max-width: 100%;
    font-size: 15px;
    line-height: 1.45;
  }

  .selector-block,
  .selector-block.compact,
  .analysis-head,
  .apps-panel,
  .matrix-head,
  .compact-analytics {
    padding: 20px 14px;
  }

  .step-head {
    grid-template-columns: 34px 1fr;
    gap: 10px;
    margin-bottom: 14px;
  }

  .step-num,
  .step-number {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    font-size: 14px;
  }

  .step-head h2,
  .selector-block h2,
  .analysis-head h2,
  .matrix-head h2,
  .matrix-head h3,
  .apps-panel h2,
  .apps-panel h3 {
    font-size: 19px;
    line-height: 1.2;
  }

  .step-head p,
  .selector-block p,
  .analysis-head p,
  .apps-panel p,
  .matrix-head p {
    font-size: 13px;
    line-height: 1.35;
  }

  /* Mobile selections must be readable vertical lists */
  .market-row,
  .segment-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    overflow: visible;
  }

  .market-card,
  .segment-card {
    min-height: auto;
    padding: 14px;
    border-radius: 15px;
  }

  .market-card strong,
  .segment-card strong {
    margin-bottom: 10px;
    font-size: 16px;
    line-height: 1.25;
  }

  .market-meta,
  .segment-meta {
    gap: 7px;
  }

  .badge,
  .market-card span,
  .segment-card span,
  .empty-facts span {
    min-height: 25px;
    padding: 4px 9px;
    font-size: 12px;
  }

  .analysis-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .toolbar input,
  #capabilitySearch {
    min-height: 44px;
    border-radius: 13px;
  }

  /* Groups: two-column chips where possible */
  .group-chips {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .group-chip,
  #groupChips button {
    width: 100%;
    min-height: 38px;
    justify-content: space-between;
    padding: 0 10px;
    font-size: 12px;
    white-space: normal;
    text-align: left;
  }

  .group-chip span,
  #groupChips button span {
    min-width: 26px;
    height: 26px;
    padding: 0 7px;
  }

  /* Participants */
  .apps-panel .panel-head,
  .apps-panel > div:first-child {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .apps-row,
  .apps-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .app-card {
    min-height: 54px;
    padding: 10px;
    gap: 9px;
    border-radius: 13px;
    font-size: 13px;
  }

  .app-card img,
  .app-placeholder {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  /* Analytics */
  .matrix-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .legend {
    justify-content: flex-start;
    gap: 10px;
    font-size: 12px;
  }

  .compact-analytics__head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin-bottom: 12px;
  }

  .compact-analytics__head h3 {
    font-size: 17px;
  }

  .compact-analytics__head p {
    font-size: 13px;
  }

  .compact-table-wrap {
    overflow-x: auto;
    border-radius: 14px;
  }

  .compact-summary-table {
    min-width: 520px;
  }

  .compact-summary-table th,
  .compact-summary-table td {
    padding: 10px;
    font-size: 12px;
  }

  .compact-app img {
    width: 28px;
    height: 28px;
  }

  .compact-note {
    font-size: 12px;
    line-height: 1.35;
  }

  .matrix-details > summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    padding: 13px 14px;
    font-size: 15px;
  }

  .matrix-table {
    min-width: 620px;
  }

  .matrix-table th,
  .matrix-table td {
    padding: 10px;
    font-size: 12px;
  }

  .matrix-table th:first-child,
  .matrix-table td:first-child {
    min-width: 210px;
  }

  .status-pill {
    min-width: 28px;
    height: 28px;
  }

  .empty-state {
    margin: 18px 14px;
    padding: 18px 14px;
  }

  .error {
    margin: 18px 14px;
  }
}

/* Very small phones */

@media (max-width: 420px) {
  .page {
    padding-left: 6px;
    padding-right: 6px;
  }

  .hero h1 {
    font-size: 22px;
  }

  .hero p {
    font-size: 14px;
  }

  .group-chips {
    grid-template-columns: 1fr;
  }

  .apps-row,
  .apps-list {
    grid-template-columns: 1fr;
  }

  .compact-summary-table {
    min-width: 500px;
  }

  .matrix-table {
    min-width: 580px;
  }
}

/* ===== Mobile comparison improvement: selectable apps + grouped matrix ===== */

.app-card.selectable {
  position: relative;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
}

.app-card.selectable.active {
  border-color: var(--primary-border);
  background: linear-gradient(180deg, #fff 0%, #faf9ff 100%);
}

.app-check {
  margin-left: auto;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #eef2ff;
  color: var(--primary);
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

.app-card.selectable:not(.active) .app-check {
  background: #f1f5f9;
}

.mobile-grouped-matrix {
  display: none;
}

.mobile-feature-group {
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  overflow: hidden;
}

.mobile-feature-group + .mobile-feature-group {
  margin-top: 10px;
}

.mobile-feature-group__head {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  background: #f8fafc;
  color: var(--text);
  text-align: left;
}

.mobile-feature-group__head span {
  font-weight: 760;
}

.mobile-feature-group__head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.mobile-feature-group__body {
  display: grid;
  gap: 0;
}

.mobile-feature-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.mobile-feature-row:last-child {
  border-bottom: 0;
}

.mobile-feature-title {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.25;
  font-weight: 720;
}

.mobile-feature-apps {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.mobile-app-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 999px;
  background: #f1f5f9;
}

.mobile-app-status img,
.app-mini-placeholder {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  object-fit: cover;
  background: #eef2ff;
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
}

.mobile-app-status i {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  color: #8ca0b8;
  font-style: normal;
  font-size: 12px;
  font-weight: 900;
}

.mobile-app-status.confirmed,
.mobile-app-status.detected {
  background: var(--green-soft);
}

.mobile-app-status.confirmed i,
.mobile-app-status.detected i {
  color: #087443;
}

.mobile-app-status.partial,
.mobile-app-status.suspected {
  background: #fff7d6;
}

.mobile-app-status.partial i,
.mobile-app-status.suspected i {
  color: #946200;
}

.mobile-app-status.rejected {
  background: var(--red-soft);
}

.mobile-app-status.rejected i {
  color: var(--red);
}

@media (max-width: 640px) {
  .apps-panel h2,
  .apps-panel h3 {
    font-size: 18px !important;
  }

  .apps-panel .panel-head,
  .apps-panel > div:first-child {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .apps-row,
  .apps-list {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .app-card {
    min-height: 48px !important;
    padding: 9px 10px !important;
    font-size: 12px !important;
  }

  .app-card img,
  .app-placeholder {
    width: 28px !important;
    height: 28px !important;
    border-radius: 8px !important;
  }

  .app-check {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }

  .compact-table-wrap {
    margin-bottom: 12px;
  }

  .mobile-grouped-matrix {
    display: block;
    margin-top: 16px;
  }

  .mobile-grouped-matrix h3 {
    margin: 0;
    font-size: 17px;
    line-height: 1.25;
    font-weight: 760;
  }

  .mobile-grouped-matrix > p {
    margin: 4px 0 12px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
  }

  .matrix-details {
    margin-top: 14px;
  }

  .matrix-details[open] .matrix-scroll {
    max-width: 100%;
    overflow-x: auto;
  }

  .matrix-table {
    min-width: 620px !important;
  }

  .matrix-table th,
  .matrix-table td {
    padding: 9px 10px !important;
    font-size: 12px !important;
  }
}

@media (max-width: 420px) {
  .apps-row,
  .apps-list {
    grid-template-columns: 1fr !important;
  }

  .mobile-feature-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mobile-feature-apps {
    justify-content: flex-start;
  }
}

/* =========================================================
   Fix market counters + mobile grouped matrix UX
   ========================================================= */

/* Рынок: показываем рынок как уровень выбора, без "функций" рынка */
.market-card small {
  display: none !important;
}

.market-card span,
.segment-card span {
  font-weight: 600;
}

/* Участники сравнения: это именно выбор приложений */
.app-card.selectable {
  cursor: pointer;
  position: relative;
}

.app-card.selectable .app-check {
  margin-left: auto;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2f7;
  color: #7b8797;
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  flex: 0 0 auto;
}

.app-card.selectable.active {
  border-color: #9b87ff;
  background: #fbfaff;
}

.app-card.selectable.active .app-check {
  background: #e8edff;
  color: #3156d9;
}

/* Мобильная матрица: не таблица, а читаемые группы */
.mobile-grouped-matrix {
  margin-top: 16px;
}

.mobile-grouped-matrix > h3 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
  color: #111827;
}

.mobile-grouped-matrix > p {
  margin: 0 0 12px;
  max-width: 760px;
  font-size: 14px;
  line-height: 1.45;
  color: #667085;
}

.mobile-feature-group {
  border: 1px solid #dbe4f0;
  border-radius: 18px;
  background: #fff;
  overflow: hidden;
}

.mobile-feature-group + .mobile-feature-group {
  margin-top: 12px;
}

.mobile-feature-group__head {
  width: 100%;
  border: 0;
  background: #f8fafc;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: default;
  text-align: left;
}

.mobile-feature-group__head span {
  font-size: 16px;
  line-height: 1.25;
  font-weight: 700;
  color: #111827;
}

.mobile-feature-group__head small {
  white-space: nowrap;
  font-size: 13px;
  font-weight: 700;
  color: #667085;
}

.mobile-feature-group__body {
  background: #fff;
}

.mobile-feature-row {
  padding: 12px 16px;
  border-top: 1px solid #edf2f7;
}

.mobile-feature-title {
  margin-bottom: 8px;
  font-size: 14px;
  line-height: 1.35;
  font-weight: 700;
  color: #111827;
}

.mobile-feature-apps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mobile-app-status {
  min-width: 44px;
  height: 28px;
  border-radius: 999px;
  padding: 3px 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: #f1f5f9;
  color: #94a3b8;
}

.mobile-app-status img,
.mobile-app-status .app-mini-placeholder {
  width: 20px;
  height: 20px;
  border-radius: 6px;
  object-fit: cover;
  flex: 0 0 auto;
}

.mobile-app-status i {
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
}

.mobile-app-status.confirmed,
.mobile-app-status.detected {
  background: #dcfce7;
  color: #15803d;
}

.mobile-app-status.partial,
.mobile-app-status.suspected {
  background: #fef3c7;
  color: #b45309;
}

.mobile-app-status.rejected {
  background: #fee2e2;
  color: #b91c1c;
}

/* Подробная таблица оставляем как вторичный режим */
.matrix-details {
  margin-top: 14px;
}

.matrix-details > summary {
  cursor: pointer;
}

/* Mobile-first cleanup */
@media (max-width: 640px) {
  body {
    font-size: 14px !important;
    line-height: 1.45 !important;
  }

  .page,
  .page-shell,
  .screen-card {
    width: 100% !important;
    max-width: 100% !important;
  }

  .screen-card {
    border-radius: 0 !important;
    border-left: 0 !important;
    border-right: 0 !important;
  }

  .hero,
  .page-hero {
    padding: 22px 16px !important;
  }

  .hero h1,
  .page-hero h1 {
    font-size: 24px !important;
    line-height: 1.15 !important;
    letter-spacing: -0.02em;
  }

  .hero p,
  .page-hero p {
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  .selector-block,
  .apps-panel,
  .matrix-card,
  .analysis-area {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  .market-row,
  .segment-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    overflow: visible !important;
  }

  .market-card,
  .segment-card {
    width: 100% !important;
    min-width: 0 !important;
    padding: 14px 14px !important;
    border-radius: 16px !important;
  }

  .market-card strong,
  .segment-card strong {
    font-size: 16px !important;
    line-height: 1.25 !important;
  }

  .market-card span,
  .segment-card span {
    font-size: 13px !important;
  }

  #groupChips {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    overflow: visible !important;
  }

  #groupChips button,
  .group-chip {
    width: 100% !important;
    justify-content: space-between !important;
  }

  .apps-row,
  .apps-list {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 8px !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .app-card {
    width: 100% !important;
    min-width: 0 !important;
    padding: 10px 12px !important;
  }

  .compact-analytics {
    padding: 0 !important;
  }

  .compact-table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .compact-summary-table {
    min-width: 520px !important;
  }

  .mobile-grouped-matrix {
    display: block !important;
  }

  .mobile-feature-group__head {
    padding: 12px 13px !important;
  }

  .mobile-feature-group__head span {
    font-size: 15px !important;
  }

  .mobile-feature-row {
    padding: 11px 13px !important;
  }

  .mobile-feature-title {
    font-size: 13px !important;
  }

  .mobile-feature-apps {
    gap: 5px !important;
  }

  .mobile-app-status {
    min-width: 40px !important;
    height: 26px !important;
    padding: 3px 6px !important;
  }

  .mobile-app-status img,
  .mobile-app-status .app-mini-placeholder {
    width: 18px !important;
    height: 18px !important;
  }

  .matrix-details[open] .matrix-scroll {
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .matrix-table {
    min-width: 640px !important;
  }
}

/* =========================================================
   Mobile collapsible groups + compact top block
   ========================================================= */

/* Десктоп: верхний блок спокойнее */
.hero h1,
.page-hero h1 {
  font-size: clamp(28px, 3vw, 42px) !important;
  line-height: 1.08 !important;
  letter-spacing: -0.035em !important;
}

.hero p,
.page-hero p {
  max-width: 820px !important;
  font-size: 18px !important;
  line-height: 1.45 !important;
}

/* Мобильная матрица: разделы функций сворачиваются */
.mobile-feature-group {
  display: block;
}

.mobile-feature-group__head {
  list-style: none;
  position: relative;
}

.mobile-feature-group__head::-webkit-details-marker {
  display: none;
}

.mobile-feature-group__head::after {
  content: "+";
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #eef2ff;
  color: #3156d9;
  font-size: 17px;
  line-height: 1;
  font-weight: 800;
  flex: 0 0 auto;
}

.mobile-feature-group[open] > .mobile-feature-group__head::after {
  content: "−";
}

.mobile-feature-group[open] {
  border-color: #a894ff;
  box-shadow: 0 10px 24px rgba(49, 86, 217, 0.08);
}

.mobile-feature-group:not([open]) .mobile-feature-group__body {
  display: none;
}

/* Сжатая таблица сводки */
.compact-summary-table th,
.compact-summary-table td {
  font-size: 13px !important;
  padding: 10px 12px !important;
}

.compact-app span {
  font-size: 13px !important;
}

/* Мобильный режим */
@media (max-width: 640px) {
  .hero,
  .page-hero {
    padding: 18px 14px 16px !important;
  }

  .hero h1,
  .page-hero h1 {
    font-size: 22px !important;
    line-height: 1.12 !important;
    letter-spacing: -0.03em !important;
    margin-bottom: 10px !important;
  }

  .hero p,
  .page-hero p {
    font-size: 14px !important;
    line-height: 1.42 !important;
    max-width: 100% !important;
  }

  .selector-block {
    padding-top: 18px !important;
    padding-bottom: 18px !important;
  }

  .selector-title h2,
  .selector-title h3,
  .apps-panel h2,
  .matrix-head h2,
  .matrix-head h3,
  .compact-analytics h3,
  .mobile-grouped-matrix > h3 {
    font-size: 18px !important;
    line-height: 1.2 !important;
  }

  .selector-title p,
  .apps-panel p,
  .matrix-head p,
  .compact-analytics p,
  .mobile-grouped-matrix > p {
    font-size: 13px !important;
    line-height: 1.4 !important;
  }

  .mobile-grouped-matrix {
    margin-top: 14px !important;
  }

  .mobile-feature-group {
    border-radius: 15px !important;
  }

  .mobile-feature-group + .mobile-feature-group {
    margin-top: 8px !important;
  }

  .mobile-feature-group__head {
    padding: 11px 12px !important;
    gap: 8px !important;
    cursor: pointer !important;
  }

  .mobile-feature-group__head span {
    font-size: 14px !important;
    line-height: 1.25 !important;
  }

  .mobile-feature-group__head small {
    font-size: 12px !important;
  }

  .mobile-feature-group__head::after {
    width: 22px !important;
    height: 22px !important;
    font-size: 15px !important;
  }

  .mobile-feature-row {
    padding: 10px 12px !important;
  }

  .mobile-feature-title {
    margin-bottom: 7px !important;
    font-size: 13px !important;
    line-height: 1.32 !important;
  }

  .mobile-feature-apps {
    gap: 5px !important;
  }

  .mobile-app-status {
    min-width: 38px !important;
    height: 25px !important;
    padding: 3px 5px !important;
  }

  .mobile-app-status img,
  .mobile-app-status .app-mini-placeholder {
    width: 17px !important;
    height: 17px !important;
    border-radius: 5px !important;
  }

  .mobile-app-status i {
    font-size: 11px !important;
  }

  .matrix-details {
    margin-top: 12px !important;
  }

  .matrix-details > summary {
    padding: 12px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .matrix-details > summary small {
    display: block !important;
    margin-top: 4px !important;
    font-size: 12px !important;
  }
}

/* Очень узкие экраны */
@media (max-width: 420px) {
  .hero h1,
  .page-hero h1 {
    font-size: 21px !important;
  }

  .hero p,
  .page-hero p {
    font-size: 13px !important;
  }

  .mobile-feature-group__head span {
    font-size: 13px !important;
  }
}

/* =========================================================
   Desktop grouped matrix structural layout
   ========================================================= */

@media (min-width: 861px) {
  .screen-card {
    padding-top: 34px !important;
  }

  .hero,
  .page-hero {
    padding: 22px 0 26px !important;
    margin-bottom: 18px !important;
  }

  .hero h1,
  .page-hero h1 {
    font-size: 30px !important;
    line-height: 1.12 !important;
    letter-spacing: -0.035em !important;
    margin: 0 0 10px !important;
  }

  .hero p,
  .page-hero p {
    max-width: 920px !important;
    font-size: 15px !important;
    line-height: 1.45 !important;
    margin: 0 !important;
  }

  .selector-block {
    padding: 22px 0 !important;
  }

  .selector-heading {
    gap: 12px !important;
    margin-bottom: 14px !important;
  }

  .selector-heading b {
    width: 32px !important;
    height: 32px !important;
    border-radius: 10px !important;
    font-size: 15px !important;
  }

  .selector-heading h2 {
    font-size: 22px !important;
    line-height: 1.15 !important;
    margin: 0 0 4px !important;
  }

  .selector-heading p {
    font-size: 14px !important;
    line-height: 1.35 !important;
    margin: 0 !important;
  }

  .market-row,
  .segment-row {
    gap: 14px !important;
  }

  .market-card,
  .segment-card {
    min-height: 82px !important;
    padding: 18px 20px !important;
    border-radius: 16px !important;
  }

  .market-card strong,
  .segment-card strong {
    font-size: 17px !important;
    line-height: 1.2 !important;
    margin-bottom: 10px !important;
  }

  .market-card span,
  .segment-card span {
    font-size: 13px !important;
    line-height: 1.15 !important;
    padding: 6px 10px !important;
    border-radius: 999px !important;
  }

  .analysis-head {
    padding: 24px 0 20px !important;
  }

  .analysis-head h2,
  #currentSegmentTitle {
    font-size: 24px !important;
    line-height: 1.15 !important;
    margin: 0 0 8px !important;
  }

  .analysis-head p,
  #currentSegmentMeta {
    font-size: 15px !important;
    line-height: 1.4 !important;
  }

  #capabilitySearch {
    height: 46px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
  }

  .group-chips {
    gap: 10px !important;
  }

  .group-chip,
  #groupChips button {
    height: 38px !important;
    padding: 0 12px !important;
    font-size: 13px !important;
    border-radius: 999px !important;
  }

  .apps-panel {
    padding: 24px 0 !important;
  }

  .apps-panel h2,
  .apps-panel h3 {
    font-size: 21px !important;
    line-height: 1.2 !important;
  }

  .apps-row,
  .apps-list {
    grid-template-columns: repeat(5, minmax(160px, 1fr)) !important;
    gap: 12px !important;
  }

  .app-card {
    min-height: 58px !important;
    padding: 12px 14px !important;
    border-radius: 14px !important;
    gap: 10px !important;
  }

  .app-card img,
  .app-card .app-placeholder {
    width: 34px !important;
    height: 34px !important;
    border-radius: 10px !important;
  }

  .app-card span {
    font-size: 14px !important;
    line-height: 1.15 !important;
  }

  .matrix-card {
    padding: 26px 0 0 !important;
  }

  .matrix-head {
    margin-bottom: 18px !important;
  }

  .matrix-head h2,
  .matrix-head h3,
  #matrixTitle {
    font-size: 23px !important;
    line-height: 1.15 !important;
    margin-bottom: 6px !important;
  }

  .matrix-head p,
  #matrixSubtitle {
    font-size: 14px !important;
    line-height: 1.35 !important;
  }

  .compact-analytics {
    display: block !important;
  }

  .compact-analytics__head {
    padding: 0 0 14px !important;
    margin-bottom: 0 !important;
  }

  .compact-analytics__head h3 {
    font-size: 20px !important;
    line-height: 1.2 !important;
    margin: 0 0 4px !important;
  }

  .compact-analytics__head p {
    font-size: 14px !important;
    margin: 0 !important;
  }

  .compact-table-wrap {
    border-radius: 16px !important;
    margin-bottom: 14px !important;
    overflow: hidden !important;
  }

  .compact-summary-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .compact-summary-table th,
  .compact-summary-table td {
    padding: 12px 14px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
  }

  .compact-app {
    gap: 10px !important;
  }

  .compact-app img,
  .compact-app .app-placeholder {
    width: 30px !important;
    height: 30px !important;
    border-radius: 9px !important;
  }

  .desktop-grouped-matrix {
    display: block !important;
    margin-top: 22px !important;
  }

  .desktop-grouped-matrix__head {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: space-between !important;
    gap: 20px !important;
    margin-bottom: 14px !important;
  }

  .desktop-grouped-matrix__head h3 {
    font-size: 22px !important;
    line-height: 1.18 !important;
    margin: 0 0 6px !important;
  }

  .desktop-grouped-matrix__head p {
    max-width: 760px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: #667085 !important;
    margin: 0 !important;
  }

  .desktop-grouped-matrix__head > span {
    flex: 0 0 auto !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    color: #667085 !important;
    background: #f3f6fb !important;
    border: 1px solid #dbe5f1 !important;
    border-radius: 999px !important;
    padding: 8px 12px !important;
  }

  .desktop-feature-group {
    border: 1px solid #dbe5f1 !important;
    border-radius: 18px !important;
    background: #ffffff !important;
    overflow: hidden !important;
    margin-bottom: 12px !important;
  }

  .desktop-feature-group[open] {
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06) !important;
  }

  .desktop-feature-group > summary {
    list-style: none !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 16px !important;
    padding: 16px 18px !important;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%) !important;
    border-bottom: 1px solid transparent !important;
  }

  .desktop-feature-group[open] > summary {
    border-bottom-color: #e4ebf5 !important;
  }

  .desktop-feature-group > summary::-webkit-details-marker {
    display: none !important;
  }

  .desktop-feature-group > summary span {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 10px !important;
    font-size: 17px !important;
    font-weight: 900 !important;
    color: #101828 !important;
  }

  .desktop-feature-group > summary span::before {
    content: "›" !important;
    width: 22px !important;
    height: 22px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 999px !important;
    background: #eef2ff !important;
    color: #3454d1 !important;
    font-weight: 900 !important;
    transform: rotate(0deg) !important;
    transition: transform .16s ease !important;
  }

  .desktop-feature-group[open] > summary span::before {
    transform: rotate(90deg) !important;
  }

  .desktop-feature-group > summary small {
    font-size: 13px !important;
    font-weight: 800 !important;
    color: #536177 !important;
    background: #eef2f7 !important;
    border-radius: 999px !important;
    padding: 7px 11px !important;
  }

  .desktop-feature-table-wrap {
    width: 100% !important;
    overflow-x: auto !important;
  }

  .desktop-feature-table {
    width: 100% !important;
    min-width: 720px !important;
    border-collapse: collapse !important;
  }

  .desktop-feature-table th,
  .desktop-feature-table td {
    padding: 13px 16px !important;
    border-bottom: 1px solid #e4ebf5 !important;
    vertical-align: middle !important;
    font-size: 13px !important;
    line-height: 1.25 !important;
  }

  .desktop-feature-table tr:last-child td {
    border-bottom: none !important;
  }

  .desktop-feature-table th {
    background: #f7f9fc !important;
    color: #475467 !important;
    font-weight: 900 !important;
    text-align: center !important;
    white-space: nowrap !important;
  }

  .desktop-feature-table th:first-child,
  .desktop-feature-table td:first-child {
    width: 46% !important;
    text-align: left !important;
  }

  .desktop-feature-table td:not(:first-child) {
    text-align: center !important;
  }

  .desktop-feature-table .cap-title {
    font-size: 14px !important;
    line-height: 1.25 !important;
    font-weight: 850 !important;
    color: #101828 !important;
  }

  .technical-matrix {
    margin-top: 18px !important;
    border: 1px solid #dbe5f1 !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    background: #fff !important;
  }

  .technical-matrix > summary {
    padding: 16px 18px !important;
    background: #f8fbff !important;
  }

  .technical-matrix .matrix-table th,
  .technical-matrix .matrix-table td {
    padding: 12px 14px !important;
    font-size: 13px !important;
  }

  .mobile-grouped-matrix {
    display: none !important;
  }
}

@media (max-width: 860px) {
  .desktop-grouped-matrix {
    display: none !important;
  }

  .mobile-grouped-matrix {
    display: block !important;
  }
}

/* =========================================================
   Desktop container width stabilization
   Fix: page was stretched full-width after grouped matrix patch
   ========================================================= */

@media (min-width: 861px) {
  body {
    background: #f4f7fb !important;
  }

  .page,
  .page-shell {
    width: 100% !important;
    max-width: 1480px !important;
    margin: 0 auto !important;
    padding: 28px 32px 56px !important;
    box-sizing: border-box !important;
  }

  .screen-card,
  .page-card {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 34px 56px 48px !important;
    border-radius: 28px !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
  }

  .hero,
  .page-hero {
    max-width: 980px !important;
    padding: 10px 0 26px !important;
    margin: 0 !important;
  }

  .hero h1,
  .page-hero h1 {
    max-width: 760px !important;
    font-size: 30px !important;
    line-height: 1.12 !important;
    margin: 0 0 12px !important;
  }

  .hero p,
  .page-hero p {
    max-width: 920px !important;
    font-size: 15px !important;
    line-height: 1.45 !important;
  }

  .selector-block,
  .apps-panel,
  .matrix-card {
    max-width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-sizing: border-box !important;
  }

  .market-row {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 14px !important;
    width: 100% !important;
  }

  .segment-row {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px !important;
    width: 100% !important;
  }

  .market-card,
  .segment-card {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    min-height: 92px !important;
    padding: 20px 22px !important;
    box-sizing: border-box !important;
  }

  .analysis-head {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 420px !important;
    align-items: center !important;
    gap: 28px !important;
  }

  #capabilitySearch {
    width: 100% !important;
    max-width: 420px !important;
    justify-self: end !important;
  }

  .group-chips {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
    max-width: 100% !important;
  }

  .apps-row,
  .apps-list {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: 12px !important;
    width: 100% !important;
  }

  .compact-analytics,
  .desktop-grouped-matrix,
  .compact-table-wrap,
  .technical-matrix,
  .matrix-details {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .desktop-grouped-matrix__head {
    max-width: 100% !important;
  }

  .desktop-feature-group {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .desktop-feature-table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
  }

  .desktop-feature-table {
    width: 100% !important;
    min-width: 880px !important;
    table-layout: fixed !important;
  }

  .desktop-feature-table th:first-child,
  .desktop-feature-table td:first-child {
    width: 38% !important;
  }

  .desktop-feature-table th:not(:first-child),
  .desktop-feature-table td:not(:first-child) {
    width: auto !important;
    text-align: center !important;
  }

  .compact-summary-table {
    width: 100% !important;
    table-layout: fixed !important;
  }

  .compact-summary-table th:first-child,
  .compact-summary-table td:first-child {
    width: 34% !important;
  }
}

@media (min-width: 861px) and (max-width: 1180px) {
  .page,
  .page-shell {
    padding: 22px 22px 44px !important;
  }

  .screen-card,
  .page-card {
    padding: 30px 34px 42px !important;
  }

  .market-row,
  .segment-row {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .apps-row,
  .apps-list {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }

  .analysis-head {
    grid-template-columns: 1fr !important;
  }

  #capabilitySearch {
    justify-self: start !important;
    max-width: 520px !important;
  }
}

/* ===== Hide technical matrix from public capabilities UI ===== */

.matrix-details {
  display: none !important;
}


/* ===== Expand/collapse state for grouped capabilities matrix ===== */

.mobile-feature-group__body {
  display: none;
}

.mobile-feature-group.open .mobile-feature-group__body {
  display: block;
}

.mobile-feature-group.open .mobile-feature-group__head {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom-color: rgba(37, 99, 235, 0.22);
}

.mobile-feature-group.open .mobile-feature-group__head::before {
  transform: rotate(90deg);
}

.mobile-feature-group__head {
  cursor: pointer;
  user-select: none;
}

@media (hover: hover) {
  .mobile-feature-group__head:hover {
    border-color: rgba(79, 70, 229, 0.35);
    background: rgba(248, 250, 255, 0.96);
  }
}


/* ===== Reliable mobile grouped matrix expand/collapse ===== */

.mobile-feature-group .mobile-feature-group__head {
  cursor: pointer;
}

.mobile-feature-group:not([open]):not(.open) .mobile-feature-group__body {
  display: none !important;
}

.mobile-feature-group[open] .mobile-feature-group__body,
.mobile-feature-group.open .mobile-feature-group__body {
  display: block !important;
}

.mobile-feature-group[open] > .mobile-feature-group__head::after,
.mobile-feature-group.open > .mobile-feature-group__head::after {
  content: "−" !important;
}

.mobile-feature-group:not([open]):not(.open) > .mobile-feature-group__head::after {
  content: "+" !important;
}

.mobile-feature-group[open],
.mobile-feature-group.open {
  border-color: #a894ff;
  box-shadow: 0 10px 24px rgba(49, 86, 217, 0.08);
}


/* ===== Missing feature state: red dash, confirmed state: green check ===== */

.mobile-app-status.not_mapped,
.mobile-app-status.missing,
.mobile-app-status.empty,
.mobile-app-status.false,
.mobile-app-status.no,
.mobile-app-status.rejected,
.mobile-app-status.unconfirmed,
.mobile-app-status.unknown {
  background: #fff1f2 !important;
  color: #e11d48 !important;
}

.mobile-app-status.not_mapped i,
.mobile-app-status.missing i,
.mobile-app-status.empty i,
.mobile-app-status.false i,
.mobile-app-status.no i,
.mobile-app-status.rejected i,
.mobile-app-status.unconfirmed i,
.mobile-app-status.unknown i {
  color: #e11d48 !important;
}

.mobile-app-status.confirmed,
.mobile-app-status.detected,
.mobile-app-status.yes,
.mobile-app-status.true {
  background: #dcfce7 !important;
  color: #15803d !important;
}

.mobile-app-status.confirmed i,
.mobile-app-status.detected i,
.mobile-app-status.yes i,
.mobile-app-status.true i {
  color: #15803d !important;
}

.status-pill.not_mapped,
.status-pill.missing,
.status-pill.empty,
.status-pill.false,
.status-pill.no,
.status-pill.rejected,
.status-pill.unconfirmed,
.status-pill.unknown {
  background: #fff1f2 !important;
  color: #e11d48 !important;
}

.status-pill.confirmed,
.status-pill.detected,
.status-pill.yes,
.status-pill.true {
  background: #dcfce7 !important;
  color: #15803d !important;
}


/* ===== Capabilities footer, restored from main ConTrend layout ===== */

.capabilities-footer.site-footer {
  width: 100%;
  margin: 72px 0 0;
  padding: 64px 0 32px;
  background: #ffffff;
  border-top: 1px solid #e5edf7;
  color: #0f172a;
}

.capabilities-footer *,
.capabilities-footer *::before,
.capabilities-footer *::after {
  box-sizing: border-box;
}

.capabilities-footer a {
  color: inherit;
  text-decoration: none;
}

.capabilities-footer a:hover {
  color: #3156d9;
}

.capabilities-footer .site-footer__inner {
  width: min(1280px, calc(100% - 56px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) minmax(180px, 0.7fr) minmax(280px, 1fr);
  gap: 64px;
  align-items: start;
}

.capabilities-footer .site-footer__brand,
.capabilities-footer .site-footer__col,
.capabilities-footer .site-footer__contact {
  min-width: 0;
}

.capabilities-footer .site-footer__logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.capabilities-footer .site-footer__logo-row strong {
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #0f172a;
}

.capabilities-footer .site-footer__logo-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #3156d9, #7c3aed);
  box-shadow: 0 16px 34px rgba(49, 86, 217, 0.22);
  flex: 0 0 auto;
}

.capabilities-footer .site-footer__brand p,
.capabilities-footer .site-footer__contact p {
  margin: 0;
  max-width: 520px;
  color: #66748a;
  font-size: 18px;
  line-height: 1.5;
}

.capabilities-footer .site-footer__title {
  margin: 0 0 18px;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 850;
  color: #0f172a;
}

.capabilities-footer .site-footer__links,
.capabilities-footer .site-footer__contact {
  display: grid;
  gap: 12px;
}

.capabilities-footer .site-footer__links a,
.capabilities-footer .site-footer__contact a {
  color: #475569;
  font-size: 17px;
  line-height: 1.35;
  font-weight: 650;
}

.capabilities-footer .site-footer__contact a {
  color: #2563eb;
  font-weight: 800;
}

.capabilities-footer .site-footer__bottom {
  width: min(1280px, calc(100% - 56px));
  margin: 44px auto 0;
  padding-top: 24px;
  border-top: 1px solid #e5edf7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #94a3b8;
  font-size: 16px;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .capabilities-footer .site-footer__inner {
    grid-template-columns: 1fr 1fr;
    gap: 36px;
  }

  .capabilities-footer .site-footer__brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .capabilities-footer.site-footer {
    margin-top: 44px;
    padding: 38px 0 96px;
    overflow: hidden;
  }

  .capabilities-footer .site-footer__inner,
  .capabilities-footer .site-footer__bottom {
    width: min(100% - 32px, 420px);
  }

  .capabilities-footer .site-footer__inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .capabilities-footer .site-footer__brand {
    grid-column: auto;
  }

  .capabilities-footer .site-footer__logo-row {
    gap: 12px;
    margin-bottom: 18px;
  }

  .capabilities-footer .site-footer__logo-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .capabilities-footer .site-footer__logo-row strong {
    font-size: 26px;
  }

  .capabilities-footer .site-footer__brand p,
  .capabilities-footer .site-footer__contact p {
    max-width: 100%;
    font-size: 16px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .capabilities-footer .site-footer__title {
    margin-bottom: 14px;
    font-size: 18px;
  }

  .capabilities-footer .site-footer__links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .capabilities-footer .site-footer__links a {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 14px;
    border: 1px solid #dbe5f2;
    border-radius: 999px;
    background: #ffffff;
    color: #475569;
    font-size: 15px;
    font-weight: 750;
    line-height: 1;
    white-space: nowrap;
  }

  .capabilities-footer .site-footer__contact {
    gap: 10px;
  }

  .capabilities-footer .site-footer__contact a {
    font-size: 18px;
    overflow-wrap: anywhere;
  }

  .capabilities-footer .site-footer__bottom {
    margin-top: 30px;
    padding-top: 20px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    font-size: 14px;
  }
}

@media (max-width: 420px) {
  .capabilities-footer .site-footer__inner,
  .capabilities-footer .site-footer__bottom {
    width: calc(100% - 24px);
  }

  .capabilities-footer .site-footer__links a {
    min-height: 40px;
    padding: 9px 12px;
    font-size: 14px;
  }

  .capabilities-footer .site-footer__contact a {
    font-size: 17px;
  }
}


/* ===== Capabilities footer spacing + mobile bottom navigation ===== */

.capabilities-footer.site-footer {
  margin-top: 44px !important;
}

@media (max-width: 760px) {
  .capabilities-footer.site-footer {
    margin-top: 28px !important;
    padding-bottom: 112px !important;
  }

  body {
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .screen-card,
  .page-card,
  .analysis-area,
  .matrix-card,
  .compact-analytics,
  .mobile-grouped-matrix {
    scroll-margin-bottom: 112px;
  }
}

/* Mobile bottom nav copied in capabilities scope to avoid dependency on index styles */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 760px) {
  .mobile-bottom-nav {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    padding: 8px;
    border: 1px solid #dbe4f0;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    transform: translateY(0);
    transition: transform 0.22s ease, opacity 0.22s ease;
  }

  .mobile-bottom-nav.is-hidden {
    transform: translateY(calc(100% + 28px));
    opacity: 0;
    pointer-events: none;
  }

  .mobile-bottom-nav__item {
    min-width: 0;
    min-height: 58px;
    padding: 8px 4px;
    border: 1px solid #edf2f7;
    border-radius: 18px;
    background: #ffffff;
    color: #64748b;
    text-decoration: none;
    font-size: 11px;
    line-height: 1.1;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-bottom-nav__item.active {
    border-color: #5b5cf6;
    background: linear-gradient(135deg, #3156d9, #6d5dfc);
    color: #ffffff;
    box-shadow: 0 10px 22px rgba(49, 86, 217, 0.25);
  }

  .mobile-bottom-nav__icon {
    font-size: 16px;
    line-height: 1;
    font-weight: 900;
  }
}

@media (max-width: 380px) {
  .mobile-bottom-nav {
    left: 8px;
    right: 8px;
    gap: 5px;
    padding: 7px;
  }

  .mobile-bottom-nav__item {
    min-height: 54px;
    border-radius: 16px;
    font-size: 10px;
  }
}


/* ===== Final fix: capabilities mobile bottom nav should not cover content ===== */

@media (max-width: 760px) {
  html {
    scroll-padding-bottom: 120px !important;
  }

  body {
    padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)) !important;
  }

  main,
  .page,
  .screen-card,
  .analysis-area,
  .matrix-card,
  .compact-analytics,
  .mobile-grouped-matrix,
  .capabilities-footer.site-footer {
    scroll-margin-bottom: 120px !important;
  }

  .screen-card {
    padding-bottom: 36px !important;
  }

  .analysis-area {
    padding-bottom: 34px !important;
  }

  .compact-analytics {
    margin-bottom: 34px !important;
  }

  .capabilities-footer.site-footer {
    margin-top: 24px !important;
    padding-bottom: calc(116px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-bottom-nav {
    left: 14px !important;
    right: 14px !important;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    padding: 7px !important;
    gap: 5px !important;
    border-radius: 22px !important;
  }

  .mobile-bottom-nav__item {
    min-height: 52px !important;
    padding: 7px 3px !important;
    border-radius: 16px !important;
    font-size: 10.5px !important;
    gap: 4px !important;
  }

  .mobile-bottom-nav__icon {
    font-size: 14px !important;
  }

  .mobile-bottom-nav.is-hidden {
    transform: translateY(calc(100% + 22px)) !important;
  }
}

@media (max-width: 420px) {
  body {
    padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .capabilities-footer.site-footer {
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
  }

  .mobile-bottom-nav {
    left: 10px !important;
    right: 10px !important;
    padding: 6px !important;
    gap: 4px !important;
  }

  .mobile-bottom-nav__item {
    min-height: 50px !important;
    font-size: 10px !important;
  }
}


/* ===== Capabilities unavailable app cards ===== */
.app-card.unavailable {
  opacity: 0.58;
  cursor: not-allowed;
  border-style: dashed;
  background: #f8fafc;
}

.app-card.unavailable:hover {
  transform: none;
  box-shadow: none;
}

.app-card.unavailable .app-check {
  background: #eef2f7;
  color: #94a3b8;
}

.app-card.unavailable span {
  color: #64748b;
}

.app-card-note {
  display: block;
  margin-left: auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: #eef2f7;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* Evidence badge in capability matrix */
.status-pill {
  gap: 4px;
}

.evidence-badge {
  display: inline-grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(52, 84, 209, 0.10);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.status-pill.confirmed .evidence-badge,
.status-pill.detected .evidence-badge {
  background: rgba(20, 163, 91, 0.13);
  color: #087443;
}
