* { box-sizing: border-box; }

html { min-width: 320px; background: var(--color-canvas); }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--color-ink);
  background: var(--color-canvas);
  font: 14px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 9px 12px;
  color: white;
  background: var(--color-brand-dark);
  border-radius: var(--radius-sm);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.prototype-ribbon {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: 28px;
  padding: 5px 16px;
  color: #574312;
  background: #fff1bd;
  border-bottom: 1px solid #ecd98d;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-shell { min-height: 100vh; padding-top: 28px; }

.sidebar {
  position: fixed;
  inset: 28px auto 0 0;
  z-index: 10;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 22px 14px 16px;
  background: #1f2921;
  color: #f5f7f3;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 10px 25px;
}

.brand__mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #1f2921;
  background: #d6e6cd;
  border-radius: 11px;
  font-size: 19px;
  font-weight: 800;
}

.brand strong, .brand small, .sidebar__footer strong, .sidebar__footer small { display: block; }
.brand strong { font-size: 16px; line-height: 1.2; }
.brand small, .sidebar__footer small { color: #aab5ab; font-size: 11px; }

.sidebar nav { flex: 1; }
.nav-label {
  margin: 19px 10px 7px;
  color: #778278;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 11px;
  margin: 2px 0;
  padding: 10px 11px;
  color: #c7cec7;
  background: transparent;
  border: 0;
  border-radius: 9px;
  text-align: left;
}

.nav-item span { width: 20px; color: #8d9b8f; text-align: center; font-size: 17px; }
.nav-item:hover { color: white; background: rgb(255 255 255 / 5%); }
.nav-item.is-active { color: white; background: #344837; }
.nav-item.is-active span { color: #c6e3c7; }

.sidebar__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 9px 2px;
  border-top: 1px solid #354139;
  font-size: 12px;
}

main { min-height: calc(100vh - 28px); margin-left: var(--sidebar-width); }

.topbar {
  position: sticky;
  top: 28px;
  z-index: 8;
  display: flex;
  height: 68px;
  align-items: center;
  justify-content: space-between;
  padding: 0 38px;
  background: rgb(255 255 255 / 92%);
  border-bottom: 1px solid var(--color-line);
  backdrop-filter: blur(12px);
}

.topbar__actions, .market-control { display: flex; align-items: center; gap: 10px; }
.market-control label { color: var(--color-ink-soft); font-size: 12px; }
.market-control select {
  min-width: 128px;
  padding: 8px 30px 8px 10px;
  color: var(--color-ink);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-weight: 700;
}

.page { max-width: 1440px; margin: 0 auto; padding: 38px; }
.page[hidden] { display: none; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 2px 0 4px; font-size: clamp(26px, 3vw, 34px); line-height: 1.16; letter-spacing: -0.035em; }
.page-heading p:not(.eyebrow) { max-width: 660px; margin: 0; color: var(--color-ink-soft); }
.eyebrow { margin: 0; color: var(--color-brand); font-size: 11px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase; }
.snapshot { align-self: center; color: var(--color-ink-soft); font-size: 12px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.8fr); gap: 16px; margin-top: 16px; }
.connections-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.mobile-nav { display: none; position: relative; }

@media (max-width: 1050px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .overview-grid { grid-template-columns: 1fr; }
  .connections-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  main { margin-left: 0; }
  .topbar { padding: 0 18px; }
  .mobile-nav { display: block; }
  .market-control label, .scope-badge, .topbar__actions .icon-button { display: none; }
  .page { padding: 26px 18px 40px; }
  .page-heading { align-items: flex-start; }
  .page-heading > button { flex: 0 0 auto; }
  .connections-grid { grid-template-columns: 1fr; }
  .table-panel { overflow-x: auto; }
  table { min-width: 760px; }
}

@media (max-width: 520px) {
  .metrics { grid-template-columns: 1fr; }
  .page-heading { display: block; }
  .page-heading > button { margin-top: 16px; }
  .toolbar { align-items: stretch !important; flex-direction: column; }
  .toolbar__count { margin-left: 0 !important; }
}
