: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,
textarea {
  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;
}

.text-kyle-button {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 48px;
  padding: 12px 16px;
  border: 1px solid #4b7f59;
  background: #1b3a27;
  color: var(--accent);
  text-decoration: none;
  font-weight: 900;
  text-transform: uppercase;
}

.text-kyle-button span {
  display: block;
  line-height: 1;
}

.text-kyle-button span {
  font-size: 16px;
}

.text-kyle-button:hover,
.text-kyle-button:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.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));
}

.filter-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  background: rgba(16, 20, 18, 0.82);
}

.sku-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 520px;
  flex-wrap: wrap;
  min-width: 0;
}

.filter-chip {
  min-width: 68px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid #31533d;
  background: #111815;
  color: var(--soft);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.filter-chip:hover,
.filter-chip:focus-visible {
  border-color: var(--accent);
}

.filter-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

.hot-filter {
  border-color: #7a5220;
  color: var(--warn);
}

.hot-deal-badge {
  display: inline-flex;
  align-items: center;
  width: max-content;
  min-height: 20px;
  padding: 3px 7px;
  border: 1px solid rgba(248, 198, 88, 0.55);
  background: rgba(248, 198, 88, 0.14);
  color: #ffd980;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.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 126px;
  gap: 16px;
  align-items: start;
}

.inventory-row.is-hot {
  box-shadow: inset 3px 0 0 var(--warn);
  background: linear-gradient(90deg, rgba(248, 198, 88, 0.08), rgba(11, 14, 12, 0.84) 28%);
}

.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;
}

.row-actions {
  min-width: 0;
}

.interest-button,
.open-email-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 34px;
  border: 1px solid #31533d;
  background: #17241c;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
}

.open-email-button.primary {
  background: #1b3a27;
  border-color: #4b7f59;
}

.interest-button:hover,
.interest-button:focus-visible,
.open-email-button:hover,
.open-email-button:focus-visible,
.dialog-close:hover,
.dialog-close:focus-visible,
.interest-form input:focus-visible,
.interest-form textarea:focus-visible {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.interest-button:disabled {
  border-color: #27302b;
  color: #5e6b62;
  background: #111612;
  cursor: not-allowed;
}

.open-email-button:disabled {
  pointer-events: none;
  border-color: #27302b;
  color: #5e6b62;
  background: #111612;
}

.trap-field {
  position: absolute;
  left: -100vw;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.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 .hot-deal-badge {
  margin-bottom: 6px;
}

.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);
}

.interest-dialog {
  width: min(560px, calc(100vw - 28px));
  max-height: calc(100vh - 18px);
  padding: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  box-shadow: var(--shadow);
}

.interest-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.interest-form {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.interest-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 2px;
}

.interest-header h2 {
  margin: 0;
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

.interest-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.dialog-close {
  flex: 0 0 auto;
  width: 34px;
  min-height: 34px;
  border: 1px solid var(--line);
  background: #111612;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.interest-listing {
  border: 1px solid var(--line);
  background: rgba(69, 224, 126, 0.04);
  padding: 0;
}

.listing-details-toggle {
  min-width: 0;
}

.listing-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 9px 10px;
  cursor: pointer;
  list-style: none;
}

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

.listing-id-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid #31533d;
  background: #111b15;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.listing-summary-text {
  min-width: 0;
}

.listing-summary-text strong,
.listing-summary-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.listing-summary-text strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
}

.listing-summary-text span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.listing-summary-cue {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.listing-details-toggle[open] .listing-summary-cue {
  color: var(--accent);
}

.interest-listing dl {
  display: grid;
  grid-template-columns: minmax(92px, 0.32fr) minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0 10px 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.interest-listing dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.interest-listing dd {
  min-width: 0;
  margin: 0;
  color: var(--soft);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.contact-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.interest-form input,
.interest-form textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  background: #0c100e;
  color: var(--text);
}

.interest-form input {
  min-height: 38px;
  padding: 8px 10px;
}

.interest-form textarea {
  height: 360px;
  min-height: 280px;
  max-height: 50vh;
  padding: 10px;
  resize: vertical;
  line-height: 1.4;
}

.interest-form textarea::placeholder {
  color: #748077;
  opacity: 1;
}

.lead-actions {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr);
  gap: 8px;
}

.interest-status {
  min-height: 18px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

@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;
  }

  .text-kyle-button {
    width: 100%;
    justify-content: center;
  }

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

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

  .filter-strip {
    align-items: stretch;
    padding: 8px;
  }

  .filter-chip {
    min-width: 66px;
  }

  .sku-filters {
    flex: 1 1 100%;
  }

  .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;
  }

  .row-actions {
    width: 100%;
  }

  .interest-button {
    width: 100%;
  }

  .lead-actions {
    grid-template-columns: 1fr;
  }

  .contact-fields {
    grid-template-columns: 1fr;
  }

  .listing-summary {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .listing-summary .hot-deal-badge {
    grid-column: 2;
    grid-row: 2;
  }

  .interest-listing dl {
    grid-template-columns: 1fr;
  }

  .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;
  }
}
