:root {
  --ink: #17211f;
  --muted: #66736e;
  --line: #d7ded8;
  --paper: #f6f7f2;
  --panel: #ffffff;
  --field: #eef3ed;
  --veris: #087a72;
  --survey: #d69b2d;
  --risk: #b35642;
  --blueprint: #28516c;
  --violet: #5d567a;
  --shadow: 0 20px 60px rgba(23, 33, 31, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(40, 81, 108, 0.09) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(8, 122, 114, 0.07) 1px, transparent 1px) 0 0 / 34px 34px,
    var(--paper);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.portal {
  width: min(1720px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.masthead {
  padding: 24px 0 22px;
}

.brandline {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 2px solid var(--veris);
  background:
    linear-gradient(135deg, transparent 44%, var(--survey) 45% 55%, transparent 56%),
    linear-gradient(45deg, transparent 44%, var(--blueprint) 45% 55%, transparent 56%);
}

.masthead-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  gap: 24px;
  align-items: end;
}

.eyebrow,
label,
.panel-heading span,
.selected-category span,
dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.eyebrow {
  margin: 0 0 8px;
}

h1 {
  max-width: 920px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 5.6vw, 6.7rem);
  font-weight: 500;
  line-height: 0.92;
}

.summary-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.summary-panel div {
  min-height: 118px;
  padding: 16px;
  border-right: 1px solid var(--line);
}

.summary-panel div:last-child {
  border-right: 0;
}

.summary-panel span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.summary-panel strong {
  display: block;
  margin-top: 12px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  line-height: 1;
  font-weight: 500;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px 190px 104px;
  gap: 12px;
  margin: 18px 0;
}

label {
  display: grid;
  gap: 6px;
}

input,
select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 12px;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 0 14px;
  text-decoration: none;
  cursor: pointer;
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.layout {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr) 380px;
  gap: 18px;
  align-items: start;
}

.category-panel,
.inspector,
.selected-category,
.macro-card,
.empty-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.category-panel,
.inspector {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.category-list {
  display: grid;
}

.category-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.category-card:hover,
.category-card.active {
  background: #edf4ef;
}

.category-card span {
  min-width: 0;
  font-weight: 800;
}

.category-card strong {
  color: var(--veris);
}

.category-card small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.macro-workspace {
  min-width: 0;
}

.selected-category {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 16px;
}

.selected-category strong {
  display: block;
  margin-top: 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  font-weight: 500;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.mini-stats span {
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: var(--field);
  color: var(--ink);
  font-size: 0.82rem;
  text-transform: none;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.macro-card {
  display: grid;
  gap: 10px;
  min-height: 210px;
  padding: 16px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.macro-card:hover,
.macro-card.active {
  outline: 2px solid var(--veris);
  outline-offset: -2px;
}

.macro-card strong {
  font-size: 1.08rem;
  line-height: 1.25;
}

.macro-card small,
.macro-card p,
.updated,
dd {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}

.macro-card p {
  margin: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

.updated {
  align-self: end;
}

.tag {
  display: inline-flex;
  width: fit-content;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  border: 1px solid var(--line);
  background: var(--field);
  font-size: 0.76rem;
  color: var(--ink);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag.deployed {
  border-color: rgba(8, 122, 114, 0.4);
  background: rgba(8, 122, 114, 0.12);
}

.tag.compiled {
  border-color: rgba(40, 81, 108, 0.35);
  background: rgba(40, 81, 108, 0.12);
}

.tag.compiled-stale,
.tag.source-only {
  border-color: rgba(179, 86, 66, 0.35);
  background: rgba(179, 86, 66, 0.11);
}

.tag.wip {
  border-color: rgba(214, 155, 45, 0.5);
  background: rgba(214, 155, 45, 0.16);
}

.tag.library {
  border-color: rgba(93, 86, 122, 0.32);
  background: rgba(93, 86, 122, 0.11);
}

.inspector {
  padding: 18px;
}

.empty-state,
.detail {
  display: grid;
  gap: 14px;
}

.empty-state {
  min-height: 260px;
  align-content: center;
}

.detail h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
  font-weight: 500;
}

.detail p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

dd {
  margin: 0 0 8px;
}

.mono {
  font-family: "Cascadia Mono", Consolas, monospace;
  overflow-wrap: anywhere;
}

.empty-card {
  padding: 28px;
  color: var(--muted);
}

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

  .category-panel,
  .inspector {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .portal {
    padding: 16px;
  }

  .summary-panel,
  .filters,
  .selected-category {
    grid-template-columns: 1fr;
  }

  .selected-category {
    display: grid;
  }

  .mini-stats {
    justify-content: flex-start;
  }
}
