:root {
  color-scheme: dark;
  --bg: #090b0a;
  --panel: #101412;
  --panel-2: #151b18;
  --line: #27302b;
  --text: #f4f7f2;
  --muted: #929c94;
  --soft: #cbd3ca;
  --accent: #45e07e;
  --accent-2: #d9f36a;
  --warn: #f2b95e;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #0c100e 0%, var(--bg) 38%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.topbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  padding: 18px 0 20px;
}

h1 {
  margin: 0;
  font-size: 54px;
  line-height: 1;
  letter-spacing: 0;
}

.topbar p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

#updated-label {
  max-width: 760px;
  font-style: italic;
  line-height: 1.45;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  min-height: 38px;
  padding: 3px;
  border: 1px solid var(--line);
  background: rgba(16, 20, 18, 0.82);
}

.segment {
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 8px 11px;
  min-width: 0;
  cursor: pointer;
}

.segment:focus-visible,
.search:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.segment.active {
  color: #07100b;
  background: var(--accent);
}

.search {
  min-width: min(320px, 100%);
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: rgba(16, 20, 18, 0.82);
  padding: 0 12px;
}

.search svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
}

.search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  font-size: 14px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-width: 0;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(21, 27, 24, 0.94), rgba(12, 16, 14, 0.96));
  box-shadow: var(--shadow);
}

.main-tabs {
  grid-template-columns: repeat(4, minmax(70px, 1fr));
}

.matches-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: rgba(11, 14, 12, 0.84);
  padding: 18px 16px 22px;
}

.matches-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.matches-list {
  display: grid;
  gap: 14px;
}

.match-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.match-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.match-id {
  padding: 4px 8px;
  background: #122018;
  color: var(--accent);
  border: 1px solid #31533d;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.match-confidence {
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.match-confidence-high {
  background: var(--accent);
  color: #07100b;
}

.match-confidence-medium {
  background: var(--accent-2);
  color: #1d2110;
}

.match-confidence-low {
  background: rgba(146, 156, 148, 0.18);
  color: var(--muted);
}

.match-sides {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: stretch;
}

.match-side {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.match-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.match-side-label {
  color: var(--accent-2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.match-side strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.match-side small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.match-arrow {
  align-self: center;
  color: var(--muted);
  font-size: 20px;
  text-align: center;
}

.match-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 10px;
  row-gap: 4px;
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.4;
}

.match-facts dt {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 10px;
  align-self: center;
}

.match-facts dd {
  margin: 0;
  color: var(--soft);
  overflow-wrap: anywhere;
}

.match-facts dd.empty {
  color: #4d574f;
}

.match-reasons,
.match-gaps {
  display: grid;
  gap: 6px;
}

.match-reasons h4,
.match-gaps h4 {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

.match-reasons ul,
.match-gaps ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.45;
}

.match-reasons li {
  color: var(--soft);
}

.match-gaps li {
  color: var(--warn);
}

.metric {
  min-width: 0;
  min-height: 86px;
  padding: 18px 20px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

.metric label {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.inventory-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  background: rgba(11, 14, 12, 0.84);
}

.table-head,
.inventory-row {
  display: grid;
  grid-template-columns: 92px 1.1fr 1.2fr 0.85fr 1.1fr 1.15fr;
  gap: 16px;
  align-items: start;
}

.table-head {
  min-height: 42px;
  padding: 14px 16px 10px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line);
}

.inventory-row {
  padding: 18px 16px;
  border-bottom: 1px solid var(--line);
}

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

.inventory-row:hover {
  background: rgba(69, 224, 126, 0.045);
}

.id-button {
  width: 82px;
  min-height: 30px;
  border: 1px solid #31533d;
  background: #122018;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.id-button:hover,
.id-button:focus-visible {
  border-color: var(--accent);
  outline: 0;
}

.id-button.copied {
  background: var(--accent);
  color: #07100b;
}

.asset {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.vendor {
  flex: 0 0 auto;
  margin-top: 1px;
  padding: 3px 6px;
  background: #124e29;
  color: #dfffea;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0;
}

.vendor-amd {
  background: #5a2b17;
  color: #ffe2cc;
}

.vendor-dc {
  background: #26394f;
  color: #d8ecff;
}

.asset-main {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
}

.asset-main strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.asset-main small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cell {
  min-width: 0;
  color: var(--soft);
  font-size: 13px;
  line-height: 1.42;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cell.empty {
  color: #4d574f;
}

.side-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  color: var(--accent-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.side-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  background: currentColor;
}

.empty-state {
  padding: 46px 16px;
  text-align: center;
  color: var(--muted);
}

@media (max-width: 820px) {
  .app-shell {
    width: calc(100% - 20px);
    max-width: 640px;
    padding-top: 16px;
  }

  h1 {
    font-size: 30px;
    line-height: 1.08;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .toolbar {
    justify-content: stretch;
  }

  .segmented,
  .search {
    width: 100%;
  }

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

  .matches-panel {
    padding: 14px 12px 18px;
  }

  .match-sides {
    grid-template-columns: 1fr;
  }

  .match-arrow {
    transform: rotate(90deg);
    font-size: 18px;
  }

  .metric {
    min-height: 72px;
    padding: 14px 12px;
  }

  .metric span {
    font-size: 26px;
  }

  .table-head {
    display: none;
  }

  .inventory-panel {
    border: 0;
    background: transparent;
  }

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

  .inventory-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 16px;
    border: 1px solid var(--line);
    background: var(--panel);
  }

  .id-button {
    width: max-content;
    min-width: 82px;
  }

  .id-button::before {
    content: "ID ";
    color: var(--muted);
    font-weight: 700;
  }

  .cell::before {
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0;
  }

  .cell[data-label="Qty / Capacity"]::before { content: "Qty / Capacity"; }
  .cell[data-label="Region"]::before { content: "Region"; }
  .cell[data-label="Timeline"]::before { content: "Timeline"; }
  .cell[data-label="Price / Terms"]::before { content: "Price / Terms"; }
}

@media (max-width: 520px) {
  .app-shell {
    width: calc(100% - 20px);
    max-width: 370px;
    margin-left: 10px;
    margin-right: auto;
  }
}
