:root {
  --ink: #16201d;
  --muted: #64716c;
  --paper: #ffffff;
  --soft: #f2f5f3;
  --line: #d7dfda;
  --green: #0b4a37;
  --green-deep: #061f19;
  --gold: #c69a2d;
  --gold-soft: #f1d47a;
  --blue: #276b8b;
  --copper: #a95f36;
  --danger: #9d382e;
  --success: #287e4c;
}

* { box-sizing: border-box; }
html { background: var(--soft); scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: system-ui, "Segoe UI", Tahoma, sans-serif;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  min-height: 70px;
  padding: 8px max(20px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  gap: 24px;
  color: #fff;
  background: var(--green-deep);
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand img {
  width: 43px;
  height: 43px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 6px;
}
.brand span { display: grid; }
.brand strong { color: var(--gold-soft); font-size: 20px; }
.brand small { color: #a8bbb2; font-size: 10px; }
.topbar nav { display: flex; align-items: center; gap: 3px; }
.topbar nav a {
  padding: 9px 11px;
  color: #d9e5df;
  text-decoration: none;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 750;
}
.topbar nav a:hover,
.topbar nav a.active { color: #fff; background: rgba(255, 255, 255, .1); }
.account-link {
  margin-inline-start: auto;
  padding: 9px 13px;
  color: #182018;
  background: var(--gold-soft);
  border-radius: 5px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
}

main { width: min(1240px, calc(100% - 32px)); margin: 0 auto; }
.market-hero {
  height: min(59vh, 540px);
  min-height: 440px;
  margin-top: 16px;
  position: relative;
  overflow: hidden;
  color: #fff;
  background: #18231f;
  border-radius: 7px;
}
.market-hero > img { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.hero-shade { position: absolute; inset: 0; background: rgba(2, 13, 11, .52); }
.hero-copy {
  width: min(680px, calc(100% - 44px));
  padding: 30px;
  position: absolute;
  inset: auto 0 18px auto;
  text-shadow: 0 2px 18px #000;
}
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: 12px; font-weight: 900; letter-spacing: 0; }
.hero-copy .eyebrow { color: var(--gold-soft); }
h1 { margin: 0; font-size: 64px; line-height: 1.08; letter-spacing: 0; }
.hero-copy > p:not(.eyebrow) { margin: 14px 0 21px; font-size: 18px; line-height: 1.85; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; }
.primary-action,
.secondary-action {
  min-height: 42px;
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 5px;
  text-decoration: none;
  cursor: pointer;
  font-weight: 850;
}
.primary-action { color: #182018; background: var(--gold-soft); }
.secondary-action { color: #fff; background: rgba(4, 19, 15, .68); border-color: rgba(255, 255, 255, .42); }
.hero-state {
  padding: 8px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: absolute;
  inset: 18px auto auto 18px;
  background: rgba(5, 25, 20, .78);
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 5px;
  font-size: 12px;
}
#runtime-dot { width: 9px; height: 9px; background: #b07b21; border-radius: 50%; }
#runtime-dot.ready { background: #54bd78; }

.market-summary {
  min-height: 92px;
  margin: 14px 0 34px;
  padding: 13px 18px;
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.market-summary dl { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)); gap: 12px 28px; flex: 1; }
.market-summary dl div { display: grid; gap: 2px; }
.market-summary dt { color: var(--muted); font-size: 11px; }
.market-summary dd { margin: 0; color: var(--green); font-size: 21px; font-weight: 900; }
.market-summary > p { width: 250px; margin: 0; color: var(--muted); line-height: 1.6; font-size: 12px; }

.catalog-section,
.markets-section,
.workflow-section { padding: 38px 0 50px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.section-heading > div { max-width: 820px; }
.section-heading h2 { margin: 0; font-size: 37px; letter-spacing: 0; }
.section-heading p:last-child { margin: 10px 0 0; color: var(--muted); line-height: 1.75; }
.section-heading > a { color: var(--green); font-size: 13px; font-weight: 850; }

.catalog-tools {
  margin-top: 24px;
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) 240px minmax(390px, auto);
  align-items: end;
  gap: 12px;
  background: #e8eeea;
  border: 1px solid #ced9d2;
  border-radius: 7px;
}
.catalog-tools label,
dialog label { display: grid; gap: 6px; }
.catalog-tools label > span,
dialog label > span { color: #52615b; font-size: 11px; font-weight: 850; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #b8c6be;
  border-radius: 5px;
}
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(39, 107, 139, .18); border-color: var(--blue); }
.kind-control {
  min-height: 42px;
  display: grid;
  grid-template-columns: repeat(5, minmax(70px, 1fr));
  border: 1px solid #b8c6be;
  border-radius: 5px;
  overflow: hidden;
}
.kind-control button {
  min-height: 40px;
  padding: 7px 8px;
  color: #4f5c57;
  background: var(--paper);
  border: 0;
  border-inline-start: 1px solid #d0d8d3;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}
.kind-control button:first-child { border-inline-start: 0; }
.kind-control button.active { color: #fff; background: var(--green); }
.catalog-result-bar { margin: 15px 0 11px; display: flex; justify-content: space-between; gap: 18px; color: var(--muted); font-size: 12px; }
.catalog-result-bar strong { color: var(--ink); }

.product-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.product-card {
  min-height: 455px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 7px;
}
.product-media { height: 166px; position: relative; overflow: hidden; background: #1b2924; }
.product-media img { width: 100%; height: 100%; object-fit: cover; }
.product-media img.emblem { object-fit: contain; padding: 28px; background: #0c2820; }
.status-chip {
  padding: 5px 8px;
  position: absolute;
  inset: 10px 10px auto auto;
  color: #fff;
  background: rgba(5, 25, 20, .86);
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 850;
}
.product-body { padding: 17px; display: flex; flex: 1; flex-direction: column; }
.product-type { color: var(--blue); font-size: 10px; font-weight: 900; }
.product-body h3 { margin: 7px 0; font-size: 20px; line-height: 1.35; }
.product-body > p { margin: 0 0 15px; color: var(--muted); line-height: 1.7; font-size: 13px; }
.product-meta { margin: auto 0 15px; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.product-meta div { padding: 10px 0 0; }
.product-meta dt { color: var(--muted); font-size: 10px; }
.product-meta dd { margin: 3px 0 0; color: var(--ink); font-size: 12px; font-weight: 800; overflow-wrap: anywhere; }
.product-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.product-action {
  min-height: 41px;
  padding: 9px 12px;
  color: #fff;
  background: var(--green);
  border: 0;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  font-weight: 850;
}
.product-technical-action {
  min-height: 41px;
  padding: 9px 12px;
  color: var(--green);
  background: #fff;
  border: 1px solid var(--green);
  border-radius: 5px;
  text-align: center;
  text-decoration: none;
  font-weight: 850;
}
.loading-state,
.empty-state { grid-column: 1 / -1; padding: 46px; color: var(--muted); text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 7px; }

.saas-band {
  margin: 12px 0 48px;
  padding: 34px;
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(440px, 1.2fr);
  gap: 36px;
  color: #fff;
  background: #14322b;
  border-top: 4px solid var(--copper);
}
.saas-band h2 { margin: 0; font-size: 34px; }
.saas-band p:not(.eyebrow) { color: #c7d5cf; line-height: 1.8; }
.saas-band button { padding: 10px 14px; color: #17211d; background: var(--gold-soft); border: 0; border-radius: 5px; cursor: pointer; font-weight: 850; }
.saas-band ol { margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; list-style: none; border: 1px solid rgba(255, 255, 255, .18); }
.saas-band li { min-height: 48px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; color: #dce8e3; border-bottom: 1px solid rgba(255, 255, 255, .12); border-inline-start: 1px solid rgba(255, 255, 255, .12); font-size: 12px; }
.saas-band li:nth-child(odd) { border-inline-start: 0; }
.saas-band li::before { content: ''; width: 6px; height: 6px; background: var(--gold-soft); border-radius: 50%; flex: 0 0 auto; }

.market-group-grid { margin-top: 24px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.market-group {
  min-height: 190px;
  padding: 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  border-inline-start: 1px solid var(--line);
}
.market-group:nth-child(4n + 1) { border-inline-start: 0; }
.market-group h3 { margin: 0 0 8px; font-size: 18px; }
.market-group p { margin: 0 0 13px; color: var(--muted); line-height: 1.65; font-size: 12px; }
.market-group button { padding: 0; color: var(--blue); background: transparent; border: 0; cursor: pointer; text-align: start; font-weight: 850; }
.sector-list { display: flex; flex-wrap: wrap; gap: 5px; }
.sector-list span { padding: 4px 6px; color: #405049; background: #edf2ef; border-radius: 4px; font-size: 10px; }

.workflow-track { margin: 24px 0 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); list-style: none; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.workflow-track li { min-height: 96px; padding: 13px; display: grid; align-content: center; gap: 5px; background: var(--paper); border-bottom: 1px solid var(--line); border-inline-start: 1px solid var(--line); }
.workflow-track li:nth-child(6n + 1) { border-inline-start: 0; }
.workflow-track span { color: var(--copper); font-size: 10px; font-weight: 900; }
.workflow-track strong { font-size: 12px; }
.workflow-track small { color: var(--muted); font-size: 9px; }

.governance-boundary { margin: 0 0 48px; padding: 18px; color: #594919; background: #fff9e9; border: 1px solid #e5d5a3; border-radius: 7px; }
.governance-boundary p { margin: 7px 0 0; line-height: 1.75; }
footer { min-height: 94px; padding: 22px max(20px, calc((100vw - 1240px) / 2)); display: flex; align-items: center; gap: 18px; color: #d8e3de; background: #172522; }
footer strong { color: var(--gold-soft); font-size: 20px; }
footer span { color: #a6b5ae; font-size: 13px; }
footer nav { margin-inline-start: auto; display: flex; gap: 16px; }
footer nav a { color: #fff; font-size: 13px; }

dialog { width: min(620px, calc(100% - 24px)); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid #bdc9c2; border-radius: 7px; box-shadow: 0 24px 80px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(2, 12, 9, .7); }
dialog form { padding: 22px; display: grid; gap: 14px; }
dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
dialog h2 { margin: 0; font-size: 27px; }
dialog header p:last-child { margin: 6px 0 0; color: var(--muted); }
.close-button { width: 38px; height: 38px; color: var(--ink); background: var(--soft); border: 1px solid var(--line); border-radius: 5px; cursor: pointer; font-size: 25px; line-height: 1; }
textarea { min-height: 110px; resize: vertical; }
.form-boundary { margin: 0; padding: 10px; color: #6d5616; background: #fff8df; border: 1px solid #ead9a4; border-radius: 5px; font-size: 12px; }
.dialog-actions { display: flex; gap: 8px; }
dialog .secondary-action { color: var(--ink); background: var(--soft); border-color: var(--line); }
#request-result { display: none; padding: 12px; color: #164f34; background: #edf8f1; border: 1px solid #bcdcc7; border-radius: 5px; line-height: 1.7; }
#request-result.visible { display: block; }
#request-result.error { color: var(--danger); background: #fff0ee; border-color: #e7b8b2; }

@media (max-width: 980px) {
  .catalog-tools { grid-template-columns: 1fr 1fr; }
  .kind-control { grid-column: 1 / -1; }
  .product-grid { grid-template-columns: 1fr 1fr; }
  .saas-band { grid-template-columns: 1fr; }
  .market-group-grid { grid-template-columns: 1fr 1fr; }
  .market-group:nth-child(4n + 1) { border-inline-start: 1px solid var(--line); }
  .market-group:nth-child(2n + 1) { border-inline-start: 0; }
  .workflow-track { grid-template-columns: repeat(4, 1fr); }
  .workflow-track li:nth-child(6n + 1) { border-inline-start: 1px solid var(--line); }
  .workflow-track li:nth-child(4n + 1) { border-inline-start: 0; }
}

@media (max-width: 690px) {
  main { width: min(100% - 20px, 1240px); }
  .topbar { display: grid; grid-template-columns: 1fr; justify-items: stretch; gap: 7px; padding: 8px 10px 6px; }
  .brand { justify-self: center; }
  .topbar nav { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .topbar nav a { padding: 7px 2px; text-align: center; font-size: 10px; overflow-wrap: anywhere; }
  .account-link { display: none; }
  .market-hero { height: 450px; min-height: 450px; margin-top: 10px; }
  .market-hero > img { object-position: 47% center; }
  .hero-copy { width: calc(100% - 20px); padding: 20px; inset-block-end: 10px; }
  h1 { font-size: 46px; }
  .hero-copy > p:not(.eyebrow) { font-size: 15px; }
  .hero-state { inset: 10px auto auto 10px; }
  .market-summary { align-items: flex-start; flex-direction: column; }
  .market-summary dl { width: 100%; grid-template-columns: 1fr 1fr; }
  .market-summary > p { width: auto; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-heading h2 { font-size: 30px; }
  .catalog-tools { grid-template-columns: 1fr; }
  .kind-control { grid-column: auto; grid-template-columns: repeat(2, 1fr); }
  .kind-control button { border-bottom: 1px solid #d0d8d3; }
  .catalog-result-bar { align-items: flex-start; flex-direction: column; }
  .product-grid { grid-template-columns: 1fr; }
  .product-card { min-height: 430px; }
  .saas-band { margin-inline: -10px; padding: 25px 18px; }
  .saas-band ol { grid-template-columns: 1fr; }
  .saas-band li { border-inline-start: 0; }
  .market-group-grid { grid-template-columns: 1fr; }
  .market-group { border-inline-start: 0; }
  .workflow-track { grid-template-columns: 1fr 1fr; }
  .workflow-track li:nth-child(4n + 1) { border-inline-start: 1px solid var(--line); }
  .workflow-track li:nth-child(2n + 1) { border-inline-start: 0; }
  footer { align-items: flex-start; flex-direction: column; }
  footer nav { margin-inline-start: 0; }
}
